I keep getting this error but I don't understand why. I formatted the variables beforehand so I should be able to do a procprint using those formatted variables.
libname hw4 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4';
data fit1;
set hw4.fit1;
run;
*Question (i-iv);
proc format;
value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers';
value txfmt 1 = "treatment" 0 = "Placebo";
value bmifmt 25-HIGH ="overweight" LOW -< 25="normal";
value bmigrp LOW -< 18= 'underweight' 18 - 25 = 'normal' 25 <- HIGH = 'normal';
run;
proc means data =fit1 p25;
*Quesition 1(v-vi);
proc format;
value cobmdfmt 0.545-HIGH = 'Above';
value blbmdfmt LOW -< 0.542 = 'less';
run;
*Question 1(c);
data fit1tmp;
set hw4.fit1;
run;
*Question 1c(ii);
proc print data=fit1(obs=5);
var dob dov;
format dob dov mmddyy10. smoker CSfmt. tx_status txfmt.;
run;
*Question 1c(iii);
proc print data=fit1(obs=5);
var dob dov Csfmt. txfmt.;
run;
NOTE: Libref HW4 was successfully assigned as follows:
Engine: V9
Physical Name: \\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4
179 data fit1;
180 set hw4.fit1;
181 run;
ERROR: You cannot open WORK.FIT1.DATA for output access with member-level control because
WORK.FIT1.DATA is in use by you in resource environment ViewTable Window.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.06 seconds
cpu time 0.01 seconds
182 *Question (i-iv);
183 proc format;
184 value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers';
NOTE: Format CSFMT is already on the library WORK.FORMATS.
NOTE: Format CSFMT has been output.
185 value txfmt 1 = "treatment" 0 = "Placebo";
NOTE: Format TXFMT is already on the library WORK.FORMATS.
NOTE: Format TXFMT has been output.
186 value bmifmt 25-HIGH ="overweight" LOW -< 25="normal";
NOTE: Format BMIFMT is already on the library WORK.FORMATS.
NOTE: Format BMIFMT has been output.
187 value bmigrp LOW -< 18= 'underweight' 18 - 25 = 'normal' 25 <- HIGH = 'normal';
NOTE: Format BMIGRP is already on the library WORK.FORMATS.
NOTE: Format BMIGRP has been output.
188 run;
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
189 proc means data =fit1 p25;
190 *Quesition 1(v-vi);
NOTE: There were 5813 observations read from the data set WORK.FIT1.
NOTE: PROCEDURE MEANS used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
191 proc format;
192 value cobmdfmt 0.545-HIGH = 'Above';
NOTE: Format COBMDFMT is already on the library WORK.FORMATS.
NOTE: Format COBMDFMT has been output.
193 value blbmdfmt LOW -< 0.542 = 'less';
NOTE: Format BLBMDFMT is already on the library WORK.FORMATS.
NOTE: Format BLBMDFMT has been output.
194 run;
NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
195 *Question 1(c);
196 data fit1tmp;
197 set hw4.fit1;
198 run;
ERROR: You cannot open WORK.FIT1TMP.DATA for output access with member-level control because
WORK.FIT1TMP.DATA is in use by you in resource environment ViewTable Window.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.00 seconds
199 *Question 1c(ii);
200 proc print data=fit1(obs=5);
201 var dob dov;
202 format dob dov mmddyy10. smoker CSfmt. tx_status txfmt.;
203 run;
NOTE: There were 5 observations read from the data set WORK.FIT1.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
204 *Question 1c(iii);
205 proc print data=fit1(obs=5);
206 var dob dov Csfmt. txfmt.;
------
22
201
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, -, /, :, _ALL_, _CHARACTER_,
_CHAR_, _NUMERIC_.
ERROR 201-322: The option is not recognized and will be ignored.
207 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
Formats have to be assigned in FORMAT statement. You can not do that in the VAR statement.
And you must close the table viewer before you run the code.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.