Hi all, I am having a problem looping through a list for class statement in the proc surveylogistic step. The code is below %let catclass = agegrp(ref="40-49") raceth(ref="NH White") maritals(ref="Married") educat(ref="Some College/College Grad") wrkstat(ref="Employed") income(ref=">= $50,000") insure(ref="No") hlthcost(ref="No") doctor(ref="No") hltstat(ref="Excellent/Very Good");
%macro ccls();
%do i = 1 %to %sysfunc(countw(&catclass));
%let logref = %scan(&catclass,&i);
%end;
%mend;
%ccls; When I loop through it, I get this error (see below). MLOGIC(REF): Beginning execution. SYMBOLGEN: Macro variable CATCLASS resolves to agegrp(ref="40-49") raceth(ref="NH White") maritals(ref="Married") educat(ref="Some College/College Grad") wrkstat(ref="Employed") income(ref=">= $50,000") insure(ref="No") hlthcost(ref="No") doctor(ref="No") hltstat(ref="Excellent/Very Good") MLOGIC(REF): %DO loop beginning; index variable I; start value is 1; stop value is 29; by value is 1. MLOGIC(REF): %LET (variable name is LOGREF) SYMBOLGEN: Macro variable CATCLASS resolves to agegrp(ref="40-49") raceth(ref="NH White") maritals(ref="Married") educat(ref="Some College/College Grad") wrkstat(ref="Employed") income(ref=">= $50,000") insure(ref="No") hlthcost(ref="No") doctor(ref="No") hltstat(ref="Excellent/Very Good") SYMBOLGEN: Macro variable I resolves to 1 MLOGIC(REF): %DO loop index variable I is now 2; loop will iterate again. MLOGIC(REF): %LET (variable name is LOGREF) SYMBOLGEN: Macro variable CATCLASS resolves to agegrp(ref="40-49") raceth(ref="NH White") maritals(ref="Married") educat(ref="Some College/College Grad") wrkstat(ref="Employed") income(ref=">= $50,000") insure(ref="No") hlthcost(ref="No") doctor(ref="No") hltstat(ref="Excellent/Very Good") SYMBOLGEN: Macro variable I resolves to 2 ERROR: Literal contains unmatched quote. ERROR: The macro REF will stop executing. MLOGIC(REF): Ending execution. Additionally, when I try it another way, I get another error. Code is below and error is after that %let ref = "40-49" "NH White" "Married" "Some College/College Grad" "Employed" ">= $50,000" "No" "No" "No" "Excellent/Very Good";
%macro ref();
%do i = 1 %to %sysfunc(countw(&ref));
%let logref = %scan(&ref,&i);
%end;
%mend;
%ref; MLOGIC(REF): Beginning execution. SYMBOLGEN: Macro variable REF resolves to "40-49" "NH White" "Married" "Some College/College Grad" "Employed" ">= $50,000" "No" "No" "No" "Excellent/Very Good" MLOGIC(REF): %DO loop beginning; index variable I; start value is 1; stop value is 19; by value is 1. MLOGIC(REF): %LET (variable name is LOGREF) SYMBOLGEN: Macro variable REF resolves to "40-49" "NH White" "Married" "Some College/College Grad" "Employed" ">= $50,000" "No" "No" "No" "Excellent/Very Good" SYMBOLGEN: Macro variable I resolves to 1 ERROR: Literal contains unmatched quote. ERROR: The macro REF will stop executing. MLOGIC(REF): Ending execution. How do I figure this out? Thanks for the help.
... View more