I have transitioned over from SAS Studio to SAS 9.4 and am running across an error where all the variables have an error of "NOTE: Format XXX was not found or could not be loaded" even though I am using the options nofmterr line before my code. Can someone assist with this? Here is my code:
118 options nofmterr;
119 data PUF2017;
120 set PUF.PUF_TRAUMA;
121 rename inc_key = patientID;
122 KEEP patientID ageyears sex asian pacificislander raceother americanindian black
122! white race_na race_uk;
123 run;
NOTE: Format SEX was not found or could not be loaded.
NOTE: Format BIU was not found or could not be loaded.
NOTE: Format YN was not found or could not be loaded.
So on & so forth...
The option NOFMTERR lets SAS run without stopping the program when format is attempted that is not available. Otherwise your data step would halt with an ERROR from the formats not found.
If you do not want those messages to appear you could clear the apparent format association in the source data set PUF.PUF_Trauma if you control the data set. That isn't friendly if someone else controls the set.
To prevent these messages from appearing when you use PUF2017 you could add a format statement to clear the associations but will get the same notes using the set that still has the association.
data PUF2017; set PUF.PUF_TRAUMA; rename inc_key = patientID; KEEP patientID ageyears sex asian pacificislander raceother americanindian black white race_na race_uk; format; run;
Probably this data set was created with formats. You either need to access those formats (contact the person who created that data set) or run this command before you try to access this data set.
options nofmterr;
the options nofmterr; was included in the SAS code I provided and I am still experiencing the error.
@PunkinSAS08 wrote:
the options nofmterr; was included in the SAS code I provided and I am still experiencing the error.
You're getting a NOTE not an error. This means your code should work as expected.
The option NOFMTERR lets SAS run without stopping the program when format is attempted that is not available. Otherwise your data step would halt with an ERROR from the formats not found.
If you do not want those messages to appear you could clear the apparent format association in the source data set PUF.PUF_Trauma if you control the data set. That isn't friendly if someone else controls the set.
To prevent these messages from appearing when you use PUF2017 you could add a format statement to clear the associations but will get the same notes using the set that still has the association.
data PUF2017; set PUF.PUF_TRAUMA; rename inc_key = patientID; KEEP patientID ageyears sex asian pacificislander raceother americanindian black white race_na race_uk; format; run;
Will this affect the rename line in my code? The patientID variable and inc_key cannot be found in the dataset now.
Try changing your KEEP statement to keep the new variable name, not the old variable name.
@PunkinSAS08 wrote:
Will this affect the rename line in my code? The patientID variable and inc_key cannot be found in the dataset now.
@PunkinSAS08 wrote:
The KEEP statement includes the new variable: data PUF2017;
set PUF.PUF_TRAUMA;
rename inc_key = patientID;
KEEP patientID ageyears sex asian pacificislander raceother americanindian black white race_na race_uk;
format;
run;
You are telling SAS that when it writes PUF2017 it should rename INC_KEY as PATIENTID. But then you tell to NOT write INC_KEY by not including it in the KEEP statement.
A mnemonic to help keep this straight is that DROP/KEEP and RENAME are applied in alphabetical order.
Here is an example that demonstrates. Notice how TEST is created with ZERO variables since NAME2 was not the name of any variable in the data step.
1217 data test; 1218 set sashelp.class; 1219 rename name=name2; 1220 keep name2; 1221 run; WARNING: The variable name2 in the DROP, KEEP, or RENAME list has never been referenced. WARNING: The variable name in the DROP, KEEP, or RENAME list has never been referenced. NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: The data set WORK.TEST has 19 observations and 0 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
This helped so much! I never knew this. Thank you
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.