Dear SAS Base Gurus,
I am trying to work something out which I am sure SAS can do but not sure how to continue with incorporating loop within macro.
Herewith the background as follows:
/*HAD THIS MACRO BELOW FROM SAS MASTER SIFU VIA GOOGLE*/
%macro intmed(dset, var);
proc means data=&dset. median noprint;
var &var.;
output out=outmed median=median;
run;
data _null_;
set outmed;
call symput("Median", median);
run;
data transform;
set &dset. end=last;
retain nl ne ng 0;
median = &median.*1;
if &var. < median then nl = nl+1;
if &var. = median then ne = ne+1;
if &var. > median then ng = ng+1;
if last then do;
if ne ne 0 then do;
intmed = median + (ng-nl)/(2*ne);
end;
else if ne = 0 then do;
intmed = median;
end;
output;
end;
label median = "Median"
intmed = "Interpolated Median";
keep median intmed;
run;
proc print data = transform label noobs;
title "Value for Median and Interpolated Median";
var median intmed;
run;
title "";
%mend;
data Survey1 (keep=Question1AreUSatisfy);
set Survey;
if Question1AreUSatisfy; /*GET RID NULL/BLANK*/
if ProgramID eq "MATH101";
run;
%intmed (Survey1, Question1AreUSatisfy);
*AT PRESENT THE MACRO JUST SHOWIN UP (OUTPUT) INTERPOLATED MEDIAN (IM) FIGURES ONE AT THE TIME BASED ON DATA SET.
*AS I AM SAS NEWBIE, I AM LOOKING ENLIGHTENMENT HOW TO DO THIS RATHER THAN 'MANUALLY' SUBSET DATA & POPULATE "IM" FIGURES.
The macro generate Interpolated Median (IM) figures in output one at a time based on unique ProgramID (Primary Key) subset data.
What I try to achieve populate IM figures automatically in the list by add in new IM field consist figure from macro (e.g.: rather than hard coding IM figure one at a time back into dataset).
As I am newbie with limited knowledge of SAS macro and loop, any enlightenment will be appreciated.
Thanks in advance.
I think so, but unfortunately it's not the case.
I have to remove blank (e.g.: null) in data steps.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.