I am having some difficulty fixing this macro code>
libname mylib 'C:\Users\Daddy\Documents'; %include 'C:\Users\Daddy\Desktop\face.sas'; %face (group,sbpbl sbp12 cholbl chol12 hdlbl hdl12 glucosbl glucos12,data=tomhs); run; %macro face (group,sbpbl, sbp12, cholbl, chol12, hdlbl, hdl12, glucosbl, glucos12,data=tomhs,dec=3,all=all); %do I = 1%to902; %let depvar = %scan(&sbpbl sbp12 cholbl chol12 hdlbl hdl12 glucosbl glucos12,&i); %let%length (&depvar) = 0 %goto done; proc tabulate data=&tomhs noseps; class &group; sbpbl&depvar; table (&group &all), (&depvar)*(n*f=7.0 mean*f=7.&dec std*f=7.&dec min*f=7.&dec max*f=7.&dec med*f=7.&dec)/rts=30; run; %end; %done: %mend face; libname mylib'C:\Users\Daddy\Documents'; %include 'C:\Users\Daddy\Desktop\face.sas' %face (group,sbpbl sbp12 cholbl chol12 hdlbl hdl12 glucosbl glucos12, data=tomhs); run;
Please how do I modify this macro code to display MEDIAN? Thanks
Are you claiming that this code works as intended, except that it fails to print the median? That would be a surprise.
Perhaps you could post the original macro, before you started playing with it. There are many issues to fix here.
The first part runs,
afterwards the remaining part never works. It gives several error that I can not fathom.
If the first part runs, then post the contents of C:\Users\Daddy\Desktop\face.sas
It may not print the median, but as long as it is working it can be tweaked to add the median to the report.
Si it fails to give an output that included MEDIAN
Hint: Set options mprint symbolgen mlogic;
Run your code;
Paste the generated statements and error messages from the log into a code box.
Mistakes from a quick scan
Oddly, the median part is actually correct....
@arrytanny wrote:
I am having some difficulty fixing this macro code>
libname mylib 'C:\Users\Daddy\Documents'; %include 'C:\Users\Daddy\Desktop\face.sas'; %face (group,sbpbl sbp12 cholbl chol12 hdlbl hdl12 glucosbl glucos12,data=tomhs); run; %macro face (group,sbpbl, sbp12, cholbl, chol12, hdlbl, hdl12, glucosbl, glucos12,data=tomhs,dec=3,all=all); %do I = 1%to902; %let depvar = %scan(&sbpbl sbp12 cholbl chol12 hdlbl hdl12 glucosbl glucos12,&i); %let%length (&depvar) = 0 %goto done; proc tabulate data=&tomhs noseps; class &group; sbpbl&depvar; table (&group &all), (&depvar)*(n*f=7.0 mean*f=7.&dec std*f=7.&dec min*f=7.&dec max*f=7.&dec med*f=7.&dec)/rts=30; run; %end; %done: %mend face; libname mylib'C:\Users\Daddy\Documents'; %include 'C:\Users\Daddy\Desktop\face.sas' %face (group,sbpbl sbp12 cholbl chol12 hdlbl hdl12 glucosbl glucos12, data=tomhs); run;Please how do I modify this macro code to display MEDIAN? Thanks
Hi:
In ;your TABLE statement, you have specified many statistics correctly -- for example, N, MEAN, STD, MIN, and MAX. However, you have this
med*f=7.&dec
in your TABLE statement and the correct specification for the MEDIAN statistic is either MEDIAN or P50, as shown in the documentation.
http://go.documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=p0n4welprckk8yn1ro9swa...
Look what happens when I try the "MED" statistic as a keyword in TABULATE:
Cynthia
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.