BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Here is the complete code followed by the error message I am getting:

%macro AgeSplit(varname=);
/***Ever reported between 9 and 13***/
/***Youngest cohort (no wave E data) ***/
if (agegrup=1 and f&varname ge 1) then &varname.m=1;
else if (agegrup=1 and g&varname ge 1) then &varname.m=1;
else if (agegrup=1 and h&varname ge 1) then &varname.m=1;
/***Middle cohort***/
else if (agegrup=2 and d&varname ge 1) then &varname.m=1;
else if (agegrup=2 and e&varname ge 1) then &varname.m=1;
else if (agegrup=2 and f&varname ge 1) then &varname.m=1;
/***Oldest cohort***/
else if (agegrup=3 and b&varname ge 1) then &varname.m=1;
else if (agegrup=3 and c&varname ge 1) then &varname.m=1;
else if (agegrup=3 and d&varname ge 1) then &varname.m=1;

else &varname.m=0;
label &varname.m='1+&lbw 14-16';
%mend;
%AgeSplit(varname=lbw);
run;

Error message:
1440 %AgeSplit(varname=lbw);
NOTE: Line generated by the invoked macro "AGESPLIT".
1 if (agegrup=1 and f&varname ge 1) then &varname.m=1;
--
180

ERROR 180-322: Statement is not valid or it is used out of proper order.

NOTE: Line generated by the invoked macro "AGESPLIT".
1 else if (agegrup=1 and g&varname ge
----
180
1 ! 1) then &varname.m=1; else if (agegrup=1 and h&varname ge 1) then &varname.m=1; else if

ERROR 180-322: Statement is not valid or it is used out of proper order.

NOTE: Line generated by the invoked macro "AGESPLIT".
1 else if (agegrup=1 and h&varname ge 1) then &varname.m=1; else if (agegrup=2 and

----

180
1 REPLY 1
SAS_user
Calcite | Level 5
You mix dataset statments with macro statements.
Try this:

data Your_dataset_result;
set your_dataset_source;
%AgeSplit(varname=lbw);
run;

************
Also you shoul not use ' when using macro.
label &varname.m='1+&lbw 14-16'; wont work
Try this:
label &varname.m="1+&lbw 14-16";

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 613 views
  • 0 likes
  • 2 in conversation