BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Paul_NYS
Obsidian | Level 7

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);

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

try adding . after &c in &c_N and other places.

&c_n should be &c._n

View solution in original post

4 REPLIES 4
Linlin
Lapis Lazuli | Level 10

try adding . after &c in &c_N and other places.

&c_n should be &c._n

Paul_NYS
Obsidian | Level 7

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

kuridisanjeev
Quartz | Level 8

Hi  paul..

Out= option not required in your first proc Sort code...

Thanks..

Sanjeev.K

Paul_NYS
Obsidian | Level 7

Thanks Sanjeev. I left that in, you are right.

Paul

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3597 views
  • 3 likes
  • 3 in conversation