Removing formats from all variables in a SAS Dataset
In SAS, every field/variable in a table/dataset can be given a format. This format tells SAS how to display the data. The following datastep will create a table called "formatted" having 1 row containing 3 variables: x, y, and d.
data formatted; x=9000; y=42; now=16761; format x comma6.; format y dollar5.; format now date7.; put x=; put y=; put now=; run;
Additionally it prints to the log the formatted values.
x=9,000 y=$42 now=21NOV05
In SAS you can also create your own formats, and you can assign these formats to whichever datasets you like. However if that format goes away for some reason and you try to look at the data again, you will get this error:
ERROR: Informat $YOURFMT not found or couldn't be loaded for variable YOURVAR.
You can get around this by turning off this option
options nofmterr;
Then your ERROR turns into NOTE, and things work normally, except when you try to view the data you see it unformatted. This could be useful, however, if you find yourself in a situation like this:
data _null_; a=20.0000001; b=20.000001; format a dollar4.2; format b dollar4.2; put a= b=; if(a=b) then put 'matches'; else put 'no match'; run;
Runs and outputs:
a=20.0 b=20.0 no match
At any rate, there are times in SAS when you simply want to remove all the formats from a dataset. This can be done in one line in a datastep:
data unformatted; set formatted; format _all_; run;