BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
MisterJenn
Fluorite | Level 6

I don't understand my I keep getting this error message.

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;
data fit1tmp;
set hw4.fit1;
run;
*Question 1 (cii); 
proc print data=fit1(obs=5);
var dob dov;
format dob dov mmddyy10. smoker CSfmt. tx_status txfmt.;
run;
*Question 1(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

NOTE: PROCEDURE GLM used (Total process time):
      real time           7:13.34
      cpu time            15.09 seconds


173  data fit1;
174  set hw4.fit1;
175  run;

NOTE: There were 5813 observations read from the data set HW4.FIT1.
NOTE: The data set WORK.FIT1 has 5813 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds


176  *Question (i-iv);
177  proc format;
178  value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers';
NOTE: Format CSFMT is already on the library WORK.FORMATS.
NOTE: Format CSFMT has been output.
179  value txfmt 1 = "treatment" 0 = "Placebo";
NOTE: Format TXFMT is already on the library WORK.FORMATS.
NOTE: Format TXFMT has been output.
180  value bmifmt 25-HIGH ="overweight" LOW -< 25="normal";
NOTE: Format BMIFMT is already on the library WORK.FORMATS.
NOTE: Format BMIFMT has been output.
181  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.
182  run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


183  proc means data =fit1 p25;
184  *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.04 seconds
      cpu time            0.03 seconds


185  proc format;
186  value cobmdfmt 0.545-HIGH = 'Above';
NOTE: Format COBMDFMT is already on the library WORK.FORMATS.
NOTE: Format COBMDFMT has been output.
187  value blbmdfmt LOW -< 0.542 = 'less';
NOTE: Format BLBMDFMT is already on the library WORK.FORMATS.
NOTE: Format BLBMDFMT has been output.
188  run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


189  data fit1tmp;
190  set hw4.fit1;
191  run;

NOTE: There were 5813 observations read from the data set HW4.FIT1.
NOTE: The data set WORK.FIT1TMP has 5813 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.01 seconds


192  *Question 1 (cii);
193  proc print data=fit1(obs=5);
194  var dob dov;
195  format dob dov mmddyy10. smoker CSfmt. tx_status txfmt.;
196  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.01 seconds


197  *Question 1(iii);
198  proc print data=fit1(obs=5);
199  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.
200  run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Skipping the parts that look like they are working let's just look at the actual mistake.

198  proc print data=fit1(obs=5);
199  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.
200  run;

You cannot specify a format in the middle of the VAR statement. 

Also you probably do not want to list the same variable, dob, twice in the VAR statement. That will just produce the some information twice in the printout.

 

If you want PROC PRINT to use different formats than those already attached to the variables add a FORMAT statement.

The syntax for a FORMAT is statement is a series of variable names followed by the formats to attach to them.   You can list one or more variables followed by one format specification, and you can do this multiple times in one FORMAT statement if you want. 

If you want to just remove any formats that might already be attached from a set of variables then do not include the format specification.  This list of variables must be the last list in the FORMAT statement for obvious reasons.

 

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

Skipping the parts that look like they are working let's just look at the actual mistake.

198  proc print data=fit1(obs=5);
199  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.
200  run;

You cannot specify a format in the middle of the VAR statement. 

Also you probably do not want to list the same variable, dob, twice in the VAR statement. That will just produce the some information twice in the printout.

 

If you want PROC PRINT to use different formats than those already attached to the variables add a FORMAT statement.

The syntax for a FORMAT is statement is a series of variable names followed by the formats to attach to them.   You can list one or more variables followed by one format specification, and you can do this multiple times in one FORMAT statement if you want. 

If you want to just remove any formats that might already be attached from a set of variables then do not include the format specification.  This list of variables must be the last list in the FORMAT statement for obvious reasons.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 296 views
  • 0 likes
  • 2 in conversation