0

I currently have a program that Generates a full report (Data Manipulation, Analysis, Formatting, Excel output) based on a few internal parameters.

I would like to build a tool or Macro that will iterate through 6 data sets, and provide a report for each of these Data sets independently.

In a process flow manner:

Input Data -> Program Operates -> Report Generation Output

I need to be able to change that Input Data Set on the fly.

Any Help would be greatly appreciated:

FYI - I've tried making a Prompt, but the "Data Source" Option does not allow me to choose a new Data Source.

mmohab
  • 2,303
  • 4
  • 27
  • 43
BGDev
  • 135
  • 1
  • 8
  • Have you tried writing a macro for this? If so, can you please share what you have tried so far – Evan Volgas May 05 '14 at 16:22
  • I have made attempts to modify, this tutorial: http://goo.gl/130rME – BGDev May 05 '14 at 16:46
  • I have not used Dictionary Tables or Memname previously. my datasets are located in one directory, but alongside many other data files. – BGDev May 05 '14 at 16:48
  • Your question is pretty generic right now. If you want something more specific, you need to make it more specific. – Joe May 05 '14 at 16:49
  • Data Source option? You may need to provide where and what that data source is. It may be easily fixed with a macro variable. – Keneni May 05 '14 at 17:00
  • The Data Source option is legitimate, but the issue is having the data source change using a Macro, or some other procedure. – BGDev May 05 '14 at 17:53

1 Answers1

0

The general structure to writing something like this is to make the data source name or connection details a macro parameter. This assumes your other steps are all the same (or are all similarly parametrized). Something like

%macro run_reports(datasource=);

proc freq data=&datasource.;
run;

%mend run_reports;

%run_reports(datasource=mydata1);
%run_reports(datasource=mydata2);

Obviously there is more complexity inside than that, but that's the basic idea. You may be able to programmatically generate the macro calls as well if there is a logical method of doing so.

Joe
  • 62,789
  • 6
  • 49
  • 67
  • Ok This is exactly the direction i would like to go. – BGDev May 05 '14 at 17:46
  • In %macro run_reports(datasource=); - Is the (datasource=) a path to the location of the data or are the data file names in a table that is ordered. – BGDev May 05 '14 at 17:47
  • That depends on your needs. In my case it's a datasetname, but if you are using a .dat file or something instead you could have the filename/path. – Joe May 05 '14 at 19:04
  • Thanks Joe, I think my main issue is that I do not know what structure the data sets need to be in. For example, If i have the data file in one file is that enough for the the macro to iterate through them. OR Do i need to have the names of each data file in an ordered chart. – BGDev May 05 '14 at 21:40
  • You don't provide nearly enough information to answer that question. You can do it almost any number of ways. All data in one file with a classification variable and/or logic to distinguish; all data in separate datasets each named appropriately; data in many different places. All can be worked with pretty easily. – Joe May 05 '14 at 21:51