BookmarkSubscribeRSS Feed
MisterJenn
Fluorite | Level 6

I need help identifying why I keep getting an error message.

libname hw4 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4';
data fit1;
set hw4.fit1;
run;
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; 
var cobmd blbmd;
format cobmd cobmdfmt. blbmd blbmd.;
run; 

 

NOTE: Copyright (c) 2016 by SAS Institute Inc., Cary, NC, USA.
NOTE: SAS (r) Proprietary Software 9.4 (TS1M6)
      Licensed to GEORGE WASHINGTON UNIVERSITY - SFA T&R, Site 70139329.
NOTE: This session is executing on the X64_DSRV19  platform.



NOTE: Analytical products:

      SAS/STAT 15.1
      SAS/ETS 15.1
      SAS/IML 15.1
      SAS/QC 15.1

NOTE: Additional host information:

 X64_DSRV19 WIN 10.0.17763  Server

NOTE: SAS initialization used:
      real time           3.53 seconds
      cpu time            1.07 seconds

1    proc means data =fit1 p25;
ERROR: File WORK.FIT1.DATA does not exist.
2    var cobmd blbmd;
ERROR: No data set open to look up variables.
ERROR: No data set open to look up variables.
3    format cobmd cobmdfmt. blbmd blbmdfmt.;
4    run;

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


5    libname hw4 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4';
NOTE: Libref HW4 was successfully assigned as follows:
      Engine:        V9
      Physical Name: \\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4
6    data fit1;
7    set hw4.fit1;
8    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


9    proc format;
10   value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers';
NOTE: Format CSFMT has been output.
11   value txfmt 1 = "treatment" 0 = "Placebo";
NOTE: Format TXFMT has been output.
12   value $bmifmt 25-HIGH ="overweight" LOW -< 25="normal";
NOTE: 25 is a numeric field and a character format is defined.
NOTE: Format $BMIFMT has been output.
13   value $bmigrp LOW -< 18= 'underweight' 18 - 25 = 'normal' 25 <- HIGH = 'normal';
NOTE: 18 is a numeric field and a character format is defined.
NOTE: Format $BMIGRP has been output.
14   run;

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


15   proc means data =fit1 p25;
16   var cobmd blbmd;
17   format cobmd cobmdfmt. blbmd blbmdfmt.;
ERROR: The format COBMDFMT was not found or could not be loaded.
18   run;

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


19   proc means data =fit1 p25;
20   var cobmd blbmd;
21   run;

NOTE: Writing HTML Body file: sashtml.htm
NOTE: There were 5813 observations read from the data set WORK.FIT1.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.45 seconds
      cpu time            0.23 seconds
2 REPLIES 2
Kurt_Bremser
Super User

The first ERROR happens because you try to use dataset fit1 before you create it.

And the format ERROR happens because you try to use a format (COBMDFMT) which you do not create in the preceding PROC FORMAT.

ballardw
Super User

Note that these format definitions

value $bmifmt 25-HIGH ="overweight" LOW -< 25="normal";
value $bmigrp LOW -< 18= 'underweight' 18 - 25 = 'normal' 25 <- HIGH = 'normal';

Are almost certainly not going to work if you use them with a character variable and cannot be used with numeric variables.

And did you INTEND to have "25<- HIGH= 'normal' " for BMIGRP??? likely should be 'overweight' or some such.

The range keywords LOW and HIGH are only really meaningful with numeric variables and ranges with character variables are pretty problematic at best and quite often do not yield expected results.

 

Why would any variable related to BMI be character in the first place??? If you want to use those ranges make sure BMI is numeric and define the format as such.

 

Example of very problematic of those character formats.

proc format;
value $bmifmt 25-HIGH ="overweight" LOW -< 25="normal";
value $bmigrp LOW -< 18= 'underweight' 18 - 25 = 'normal' 25 <- HIGH = 'overweight';
;

data example;
   input bmi $;
   Put  bmi= "with $bmifmt " bmi=$bmifmt.  "with $bmigrp " bmi1=$bmigrp. ;
datalines;
2
3
;

which yields:

512  data example;
513     input bmi $;
514     Put  bmi= "with $bmifmt " bmi=$bmifmt.  "with $bmigrp " bmi=$bmigrp. ;
515  datalines;

bmi=2 with $bmifmt bmi=normal with $bmigrp bmi=normal
bmi=3 with $bmifmt bmi=overweight with $bmigrp bmi=overweight

3 (as would 4, 5, 6 ... 9) are "overweight" because when character comparisons are performed they are done character by character until the shorter one runs out. So 3 is compared to the 2 in 25 and is "greater" so is in the "range" 25-HIGH and gets assigned to "Overweight" for BMIFMT and similar for BMIGRP.

 

Similar behavior with 2 with BMIGRP. 2 is larger than the 1 in the Low- 18 group, so is not set there but is "less than or equal" to 25 (actually "equal" to 25 as only compared to the 2) so gets assigned "normal" .

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 418 views
  • 2 likes
  • 3 in conversation