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

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