Hey all, Below is a code that I inherited for analysis on survey data. After many attempts and adjustments, I am still getting an error message that I am unsure how to resolve. Please see attached data. Please assist. Thanks. SAS Code: %let var = qn8 qn9 qn10 qn13 qn15 qn16 qn17 qn18 qn22 qn23 qn24 qn25 qn26 qn27 qn28 qn29 qn31 qn32 qn33 qn34; %macro tottable (var1, cross1, cross2, cross3, cross4, cross5, col1, varseage, col2, varsesex); %do i=1 %to %eval(%sysfunc(countc(&var., " "))+1); %let var1=%scan(&var, &i); %put var1; proc surveyfreq data=yrbs.yrbs17_bot nomcar; table Virginia*&var1./cl(type=logit) cv row ; strata stratum; cluster psu; weight weight; ods output crosstabs=part.&var1.&cross1; run; data part.&var1.&cross1; length F_Virginia $90 characteristic $195; format rowpercent rowlowercl rowuppercl 8.1 frequency comma10.; set part.&var1.&cross1; characteristic='Total'; keep characteristic f_Virginia Virginia f_&var1. &var1. frequency rowpercent rowuppercl rowlowercl; rename f_Virginia=level; rename Virginia=levnum; run; data part.&var1.&cross1; set part.&var1.&cross1; if f_&var1.="Total" then delete; run; proc surveyfreq data=yrbs.yrbs17_bot nomcar; table sex* &var1./cl(type=logit) cv row ; strata stratum; cluster psu; weight weight; ods output crosstabs=part.&var1.&cross2; run; data part.&var1.&cross2; length F_sex $90 characteristic $195; format rowpercent rowlowercl rowuppercl frequency comma10.; set part.&var1.&cross2; characteristic='Sex'; keep characteristic f_sex sex f_&var1. &var1. frequency rowpercent rowuppercl rowlowercl; rename f_sex=level; rename sex=levnum; run; data part.&var1.&cross2; set part.&var1.&cross2; if f_&var1.="Total" then delete; if level="Total" then delete; run; proc surveyfreq data=yrbs.yrbs17_bot nomcar; table raceeth2*&var1./ cl(type=logit) cv row ; strata stratum; cluster psu; weight weight; ods output crosstabs=part.&var1.&cross3; run; data part.&var1.&cross3; length F_raceeth2 $90 characteristic $195; format rowpercent rowlowercl rowuppercl frequency comma10.; set part.&var1.&cross3; characteristic='Race/Ethnicity'; keep characteristic f_raceeth2 raceeth2 f_&var1. &var1. frequency rowpercent rowuppercl rowlowercl; rename f_raceeth2=level; rename raceeth2=levnum; run; data part.&var1.&cross3; set part.&var1.&cross3; if f_&var1.="Total" then delete; if level="Total" then delete; run; proc surveyfreq data=yrbs.yrbs17_bot nomcar; table age*&var1./cl (type=logit)cv row ; strata stratum; cluster psu; weight weight; ods output crosstabs=part.&var1.&cross4; run; data part.&var1.&cross4; length F_age $90 characteristic $195; format rowpercent rowlowercl rowuppercl frequency comma10.; set part.&var1.&cross4; characteristic='Age'; keep characteristic f_age age f_&var1. &var1. frequency rowpercent rowuppercl rowlowercl; rename f_age=level; rename age=levnum; run; data part.&var1.&cross4; set part.&var1.&cross4; if f_&var1.="Total" then delete; if level="Total" then delete; run; proc surveyfreq data=yrbs.yrbs17_bot nomcar; table grade*&var1./cl (type=logit) cv row ; strata stratum; cluster psu; weight weight; ods output crosstabs=part.&var1.&cross5; run; data part.&var1.&cross5; length F_grade $90 characteristic $195; format rowpercent rowlowercl rowuppercl frequency comma10.; set part.&var1.&cross5; characteristic='Grade'; keep characteristic f_grade grade f_&var1. &var1. frequency rowpercent rowuppercl rowlowercl; rename f_grade=level; rename grade=levnum; run; data part.&var1.&cross5; set part.&var1.&cross5; if f_&var1.="Total" then delete; if level="Total" then delete; run; data part.&var1.&col1; retain &var1. characteristic level levnum frequency rowpercent rowlowercl rowuppercl; set part.&var1.&cross1 - part.&var1.&cross5; keep f_&var1. characteristic level levnum frequency rowpercent rowlowercl rowuppercl; if f_&var1.='Yes' then output part.&var1.&col1; run; data part.&var1.&col2; retain &var1. characteristic level levnum frequency rowpercent rowlowercl rowuppercl; set part.&var1.&cross1 - part.&var1.&cross5; keep f_&var1. characteristic level levnum frequency rowpercent rowlowercl rowuppercl; if f_&var1.='No' then output part.&var1.&col2; run; data part.&var1.&col1; set part.&var1.&col1; ci&varseage=cat(' (',strip(put(rowlowercl,8.1)),' - ', strip(put(rowuppercl,8.1)),')'); keep characteristic level levnum frequency rowpercent ci&varseage /*rowstderr*/ rowlowercl rowuppercl; rename frequency=f&varseage; rename rowpercent=per&varseage; rename rowlowercl=lowercl&varseage; rename rowuppercl=uppercl&varseage; run; data part.&var1.&col2; set part.&var1.&col2; ci&varsesex=cat(' (',strip(put(rowlowercl,8.1)),' - ', strip(put(rowuppercl,8.1)),')'); keep characteristic level levnum frequency rowpercent ci&varsesex /*rowstderr*/ rowlowercl rowuppercl; rename frequency=f&varsesex; rename rowpercent=per&varsesex; rename rowlowercl=lowercl&varsesex; rename rowuppercl=uppercl&varsesex; run; proc sort data= part.&var1.&col1; by level; run; proc sort data= part.&var1.&col2; by level; run; data data.&var1.; merge part.&var1.&col1 part.&var1.&col2; by level; level=cat(' ',level); order=_N_; run; data data.&var1.; set data.&var1.; if characteristic='Total' then charnum=1; else if characteristic='Sex' then charnum=2; else if characteristic='Race/Ethnicity' then charnum=3; else if characteristic='Age' then charnum=4; else if characteristic='Grade' then charnum=5; run; proc sort data= data.&var1. out= data.&var1. ; by charnum levnum; run; data data.&var1.; set data.&var1.; if f1=. then f1=0; if f2=. then f2=0; if per1=. then per1=0.0; if per2=. then per2=0.0; if per1=0.0 then ci1='(. - .)'; if per2=0.0 then ci2='(. - .)'; frequency1=f1+f2; run; data data.&var1.; format frequency1 comma10.; set data.&var1.; run; data data.&var1.; set data.&var1.; frequency=strip(put(frequency1, comma10.)); per1&varseage=strip(put(per&varseage, 8.1)); per1&varsesex=strip(put(per&varsesex, 8.1)); run; %end; %mend; %tottable (var1, cross1, cross2, cross3, cross4, cross5, col1, 1, col2, 2) Error Message: var1 ERROR: Variable CL not found. ERROR: Variable CV not found. ERROR: Variable ROW not found. NOTE: Line generated by the macro variable "VAR1". 1 * -- 22 200 NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SURVEYFREQ used (Total process time): real time 0.00 seconds cpu time 0.00 seconds WARNING: Output 'crosstabs' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used. ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, *, -, /, :, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 200-322: The symbol is not recognized and will be ignored. ERROR: File PART.CROSS1.DATA does not exist. WARNING: The variable Virginia in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable f_ in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable Virginia in the DROP, KEEP, or RENAME list has never been referenced. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set PART.CROSS1 may be incomplete. When this step was stopped there were 0 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds NOTE: Variable f_ is uninitialized. NOTE: There were 0 observations read from the data set PART.CROSS1. NOTE: The data set PART.CROSS1 has 0 observations and 7 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds NOTE 137-205: Line generated by the invoked macro "TOTTABLE". 643 rowlowercl; rename f_Virginia=level; rename Virginia=levnum; run; data 643 ! part.&var1.&cross1; set part.&var1.&cross1; if f_&var1.="Total" then delete; run; 643 ! proc surveyfreq data=yrbs.yrbs17_bot nomcar; table sex* &var1./cl cv - 22 ERROR 22-322: Syntax error, expecting one of the following: a name, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR: Variable NAME not found. NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SURVEYFREQ used (Total process time): real time 0.00 seconds cpu time 0.00 seconds WARNING: Output 'crosstabs' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used. ERROR: File PART.CROSS2.DATA does not exist. WARNING: The variable sex in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable f_ in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable sex in the DROP, KEEP, or RENAME list has never been referenced. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set PART.CROSS2 may be incomplete. When this step was stopped there were 0 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds NOTE: Variable f_ is uninitialized. NOTE: There were 0 observations read from the data set PART.CROSS2. NOTE: The data set PART.CROSS2 has 0 observations and 7 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.01 seconds NOTE: Line generated by the macro variable "VAR1". 1 * - 22 200 ERROR: Variable CL not found. ERROR: Variable CV not found. ERROR: Variable ROW not found. NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SURVEYFREQ used (Total process time): real time 0.00 seconds cpu time 0.00 seconds WARNING: Output 'crosstabs' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used. ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, *, -, /, :, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 200-322: The symbol is not recognized and will be ignored. ERROR: File PART.CROSS3.DATA does not exist. WARNING: The variable raceeth2 in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable f_ in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable raceeth2 in the DROP, KEEP, or RENAME list has never been referenced. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set PART.CROSS3 may be incomplete. When this step was stopped there were 0 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds NOTE: Variable f_ is uninitialized. NOTE: There were 0 observations read from the data set PART.CROSS3. NOTE: The data set PART.CROSS3 has 0 observations and 7 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds ERROR: Variable CL not found. ERROR: Variable CV not found. ERROR: Variable ROW not found. NOTE: Line generated by the macro variable "VAR1". 1 * - 22 200 NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SURVEYFREQ used (Total process time): real time 0.00 seconds cpu time 0.00 seconds WARNING: Output 'crosstabs' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used. ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, *, -, /, :, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 200-322: The symbol is not recognized and will be ignored. ERROR: File PART.CROSS4.DATA does not exist. WARNING: The variable age in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable f_ in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable age in the DROP, KEEP, or RENAME list has never been referenced. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set PART.CROSS4 may be incomplete. When this step was stopped there were 0 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.01 seconds NOTE: Variable f_ is uninitialized. NOTE: There were 0 observations read from the data set PART.CROSS4. NOTE: The data set PART.CROSS4 has 0 observations and 7 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.01 seconds ERROR: Variable CL not found. ERROR: Variable CV not found. ERROR: Variable ROW not found. NOTE: Line generated by the macro variable "VAR1". 1 * - 22 200 NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE SURVEYFREQ used (Total process time): real time 0.00 seconds cpu time 0.00 seconds WARNING: Output 'crosstabs' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used. ERROR 22-322: Syntax error, expecting one of the following: a name, ;, (, *, -, /, :, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 200-322: The symbol is not recognized and will be ignored. ERROR: File PART.CROSS5.DATA does not exist. WARNING: The variable grade in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable f_ in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable grade in the DROP, KEEP, or RENAME list has never been referenced. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set PART.CROSS5 may be incomplete. When this step was stopped there were 0 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.01 seconds NOTE: Variable f_ is uninitialized. NOTE: There were 0 observations read from the data set PART.CROSS5. NOTE: The data set PART.CROSS5 has 0 observations and 7 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.03 seconds NOTE: Variable levnum is uninitialized. WARNING: The variable levnum in the DROP, KEEP, or RENAME list has never been referenced. NOTE: There were 0 observations read from the data set PART.CROSS1. NOTE: There were 0 observations read from the data set PART.CROSS2. NOTE: There were 0 observations read from the data set PART.CROSS3. NOTE: There were 0 observations read from the data set PART.CROSS4. NOTE: There were 0 observations read from the data set PART.CROSS5. NOTE: The data set PART.COL1 has 0 observations and 7 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.03 seconds NOTE: Variable levnum is uninitialized. WARNING: The variable levnum in the DROP, KEEP, or RENAME list has never been referenced. NOTE: There were 0 observations read from the data set PART.CROSS1. NOTE: There were 0 observations read from the data set PART.CROSS2. NOTE: There were 0 observations read from the data set PART.CROSS3. NOTE: There were 0 observations read from the data set PART.CROSS4. NOTE: There were 0 observations read from the data set PART.CROSS5. NOTE: The data set PART.COL2 has 0 observations and 7 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.01 seconds WARNING: The variable levnum in the DROP, KEEP, or RENAME list has never been referenced. NOTE: There were 0 observations read from the data set PART.COL1. NOTE: The data set PART.COL1 has 0 observations and 7 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.01 seconds WARNING: The variable levnum in the DROP, KEEP, or RENAME list has never been referenced. NOTE: There were 0 observations read from the data set PART.COL2. NOTE: The data set PART.COL2 has 0 observations and 7 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.03 seconds NOTE: Input data set is empty. NOTE: The data set PART.COL1 has 0 observations and 7 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds NOTE: Input data set is empty. NOTE: The data set PART.COL2 has 0 observations and 7 variables. NOTE: PROCEDURE SORT used (Total process time): real time 0.01 seconds cpu time 0.01 seconds NOTE: Line generated by the macro variable "VAR1". 1 data. ----- 22 201 ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;, _DATA_, _LAST_, _NULL_. ERROR 201-322: The option is not recognized and will be ignored. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DATA16 may be incomplete. When this step was stopped there were 0 observations and 13 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds NOTE: Line generated by the macro variable "VAR1". 1 data. ----- 22 201 ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, /, ;, _DATA_, _LAST_, _NULL_. ERROR 201-322: The option is not recognized and will be ignored. NOTE: Line generated by the macro variable "VAR1". 1 data. ----- 22 201 ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, CUROBS, END, INDSNAME, KEY, KEYRESET, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_. ERROR 201-322: The option is not recognized and will be ignored. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DATA17 may be incomplete. When this step was stopped there were 0 observations and 14 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
... View more