DATA Step, Macro, Functions and more

Macro issue with line/column error

Accepted Solution Solved
Reply
Regular Contributor
Posts: 216
Accepted Solution

Macro issue with line/column error

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


Accepted Solutions
Solution
‎12-26-2012 09:40 AM
Super Contributor
Posts: 1,636

Re: Macro issue with line/column error

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

&c_n should be &c._n

View solution in original post


All Replies
Solution
‎12-26-2012 09:40 AM
Super Contributor
Posts: 1,636

Re: Macro issue with line/column error

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

&c_n should be &c._n

Regular Contributor
Posts: 216

Re: Macro issue with line/column error

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

Super Contributor
Posts: 276

Re: Macro issue with line/column error

Hi  paul..

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

Thanks..

Sanjeev.K

Regular Contributor
Posts: 216

Re: Macro issue with line/column error

Posted in reply to kuridisanjeev

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

Paul

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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