Hi
I am not familiar with macros, but created one below and ran it a few times and keep getting an error for "214: LINE and COLUMN cannot be determined" and "ERROR 214-322: Variable name & is not valid." Line 214 in the below statement is the red, bolded run statement, so I am assuming SAS is barfing on the "drop _TYPE_ &c_Q3;" that precedes it. Is there any issue with using variables in macros to define column names?
Paul
%macro issueJoined (a,b,c,d);
proc sort data=&a out=&a;
by &b;
run;
proc means data=&a;
var &c;
by &b;
output out=issue1 n= nmiss= median= q3= /autoname;
run;
data issueMedian (rename=(_FREQ_=TotalChildren &c_N=NumberIssue
&c_NMiss=NumberMissingIssue &c_Median=MedianNumber
&c_Q3=ThirdQuartile));
set issue1;
if &c_N >= &c_NMiss;
drop _TYPE_ &c_Q3;
run;
data issueThirdQ (rename=(_FREQ_=TotalChildren &c_N=NumberIssue
&c_NMiss=NumberMissingIssue &c_Median=MedianNumber
&c_Q3=ThirdQuartile));
set issue1;
if &c_N >= (round(.75*_FREQ_));
drop _TYPE_ &c_Median _FREQ_ &c_N &c_NMiss;
run;
proc sort data=issueMedian;
by &b;
run;
proc sort data=issueThirdQ;
by &b;
run;
data &d;
merge issueMedian issueThirdQ;
by &b;
run;
%mend issueJoined;
%issueJoined (issuejoinedNNNA, cnty_name filingYear, dur_filing_issuejoin, issueCountiesFinal);
try adding . after &c in &c_N and other places.
&c_n should be &c._n
Thanks Linlin, that was it. When I looked at Marco language, I didn't see the period that gets added to variables when they are part of strings.
Paul
Hi paul..
Out= option not required in your first proc Sort code...
Thanks..
Sanjeev.K
Thanks Sanjeev. I left that in, you are right.
Paul
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.