Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

macrohelp for a new technical user. 1

Status
Not open for further replies.

charisi

Technical User
May 25, 2009
9
AU
I am new with SAS and trying to use a macro to obtain summary statistics only on a limited number of variables on my data.
What is the code/datastep for a macro that can enable me obtain summary statistics on my data?
 
Why not use the Proc summary, Proc Univariate, proc freq or proc means.

See the SAS help on the proper syntax for each proc. These procs are a few lines long and would be what a macro (function) would be in another programming language.

Klaz
 
thanks Klaz, Yes I have used those other codes. i was interested in macro because i wanted to use it to explore other parts of my dataset.again,what would be the required macro code/data step?
 
i have a data set and would like to run macro and obtain summary statistics for three numeric variables var2,var3,var4 against one categoric variable(var5) using
the following either of this code:

%macro examq1f(id, var2, var3, var4, var5);
proc freq;
title 'frequency tables using macro';
tables &table var &id &var2 &var3&var4 &var5;
run;
proc means n mean std median Q1 Q3 max min;
var &var2 &var3 &var4;
run;
proc sort;
by &var5;
run;
%mend examq1f;
%examq1f;
%examq1f;

or alternatively%macro examq1f(tablevar)
proc freq;
title frequency tables using a macro';
tables &tablevar;
%mend examq1f;
%examqif(var5);
%examq1f(var5);

iam failing to get an output or print out when i run this code.
what am i doing wrong klaz?
how can i get an output or print out using this macro code or is this the wrong way of running / using macro to obtain the summary statistics? how can one use macro in this scenario?
i have also tried to run; code:
options mprint mlogic symbolgen:
and still can not get macro running or give me an out put even using pro print; run;
can you please help ?
 
I am new with SAS and trying to use a macro to obtain summary statistics only on a limited number of variables on my data. What is the code/datastep for a macro that can enable me obtain summary statistics on my data?

i have a data set and would like to run macro and obtain summary statistics for three numeric variables var2,var3,var4 against one categoric variable(var5) usingthe following either of this code:%macro examq1f(id, var2, var3, var4, var5); proc freq; title 'frequency tables using macro'; tables &table var &id &var2 &var3&var4 &var5; run; proc means n mean std median Q1 Q3 max min; var &var2 &var3 &var4; run; proc sort; by &var5; run; %mend examq1f; %examq1f; %examq1f;or alternatively%macro examq1f(tablevar)proc freq;title frequency tables using a macro';tables &tablevar;%mend examq1f;%examqif(var5);%examq1f(var5);iam failing to get an output or print out when i run this code.what am i doing wrong klaz?how can i get an output or print out using this macro code or is this the wrong way of running / using macro to obtain the summary statistics? how can one use macro in this scenario?i have also tried to run; code:eek:ptions mprint mlogic symbolgen: and still can not get macro running or give me an out put even using pro print; run; can you please help ?





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top