LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 20 Oct 2010 13:11:13 -0700
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: a little macro help, quoting?
Content-Type: text/plain; charset=ISO-8859-1

Remove the quotes around the + in your %scan, i.e.:

where %SCAN(&code.,&k,+) ;

HTH, Art ----------- On Oct 20, 12:35 pm, bigD <diaphanos...@gmail.com> wrote: > Hello, > > I need to run proc means several times with different where > statements. I placed the conditions in a macro variable as shown > below. The log doesn't really give me many hints. How would this type > of problem typically be solved? > Thanks, > > BigD > > data ccodes; > input code & ~ $100.; > cards; > icd10_code1 between 'A' and 'Z9999' > icd10_code1 between 'I21' and 'I2299' > icd10_code1 between 'I20' and 'I2599' > icd10_code1 between 'I50' and 'I5199' > icd10_code1 between 'I60' and 'I6999' > icd10_code1 between 'E10' and 'E1499' > ; > run; > > PROC SQL; > select distinct code into: code separated by '+' from ccodes; > > The macro compiles, but it doesn't work the way I would like it to > work. > > %macro test; > > %do k= 1 %to 6; * k will be the disease groups; > > proc sort data=A; by age_CLASS; run; > /*pick out the codes here */ > PROC MEANS DATA=A; > where %SCAN(&code.,&k,'+') ; > BY age_class; > VAR DEATHS; > OUTPUT OUT=A_m SUM=TOTAL_DEATHS; > RUN; > > %end; > %mend; > > %test; > > LOG: > > MPRINT(TEST): PROC MEANS DATA=A; > SYMBOLGEN: Macro variable CODE resolves to icd10_code1 between 'A' > and 'Z99999'+icd10_code1 > between 'E10' and 'E1499'+icd10_code1 between 'I20' and > 'I2599'+icd10_code1 between > 'I21' and 'I2299'+icd10_code1 between 'I50' and > 'I5199'+icd10_code1 between 'I60' > and 'I6999' > SYMBOLGEN: Macro variable K resolves to 1 > NOTE 137-205: Line generated by the invoked macro "TEST". > 1 * k will be the disease groups; proc sort data=A; by > age_CLASS; run; PROC MEANS DATA=A > 1 ! ; where %SCAN(&code.,&k,'+') ; BY age_class; VAR DEATHS; OUTPUT > OUT=A_m SUM=TOTAL_DEATHS; > - > 22 > 1 ! RUN; > ERROR 22-322: Syntax error, expecting one of the following: a name, a > quoted string, > a numeric constant, a datetime constant, a missing > value, (, +, -, INPUT, NOT, > PUT, ^, ~. > > NOTE: Line generated by the invoked macro "TEST". > 1 * k will be the disease groups; proc sort data=A; by > age_CLASS; run; PROC MEANS DATA=A > 1 ! ; where %SCAN(&code.,&k,'+') ; BY age_class; VAR DEATHS; OUTPUT > OUT=A_m SUM=TOTAL_DEATHS; > - > 76 > 1 ! RUN; > ERROR 76-322: Syntax error, statement will be ignored. > > MPRINT(TEST): where icd10_code1 between ; > ERROR: Syntax error while parsing WHERE clause. > MPRINT(TEST): BY age_class; > MPRINT(TEST): VAR DEATHS; > MPRINT(TEST): OUTPUT OUT=A_m SUM=TOTAL_DEATHS; > MPRINT(TEST): RUN;


Back to: Top of message | Previous page | Main SAS-L page