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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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