- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
For class I am tasked with creating a macro program that will pull from all data sets and all numeric variables to create a histogram and summary statistics table.
Here is what I was given:
Write a macro program named ‘**********’ which may be used to summarize a numeric variable from any data set.
The macro will generate 2 pieces of output: 1) a histogram, and 2) summary statistics (i.e. the macro should contain 2 steps).
- The macro should contain the following 4 parameters:
- '*****’ to specify the data set name
- '***’ to specify the numeric variable
- ‘****’ to specify summary statistics. Include default statistics of N, MEAN, and STDDEV.
- ‘****’ to specify the number of decimals. Include a default value of 1.
This is where I'm at right now and things are not matching up very well after trying to model after an existing program:
%MACRO ********** (****** = , Stats = N MEAN STDDEV, **** = _NUMERIC_, NDec= 1 );
DATA WORK.&****;
SET &***;
WHERE *** = "&***";
RUN;
TITLE1 "***********************";
PROC MEANS
DATA = WORK.&**** &Stats;
VAR &***;
RUN;
PROC SORT DATA = WORK.&****;
BY DESCENDING &****;
RUN;
TITLE1 "*******************************";
PROC PRINT DATA = WORK.&**** ;
VAR &***;
RUN;
TITLE;
%MEND ********;
%************ (******* = &*****, **** = &****, Stats = &Stats)
I am particularly concerned about what I should place in lieu of variable names throughout the program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Step 1 in any macro writing effort is to create code without macros and without macro variables, and get it to work in one instance (such as, for one specific table and one specific variable). It does not seem as if you have done this. Once you have such a working SAS program, then it should be relatively easy to turn it into a macro. If you don't have working SAS code and try to turn it into a macro, then it will never work inside the macro.
So, show us code that works for one instance without macros and without macro variables.
Paige Miller