@geneshackman wrote: Kurt, thanks. The data set came with some cells being blank, which means no instances, and ".", which means suppressed. I only want to change the "." to *. How would I use the custom informat? I'd want it to be when missing is "." then change it to *. But if missing is blank, then do -not- change to *.
SAS has special missing values .A to .Z and ._ to allow you to have different types of missing data. So if you are reading a CSV file and you want to treat numeric variables that have an actual period in the CSV file differently than nothing at all (that is two adjacent commas) you will need to replace either the periods or the null strings with either a letter or an underscore. You might also need to issue the MISSING statement (not the MISSING option) to make sure that SAS treats the letter or underscore as meaning the special missing and not an invalid value for number.
So changing a line like:
123,.,,012
to
123,_,,012
would be interpreted as having one value of the special missing ._ and regular missing value.
You could even make the change in the same step that is reading the file by manipulating the _INFILE_ buffer. (Note: This will only work if no line in the file has more than 32K bytes since that is maximum length where you can modify the _INFILE_ buffer variable.)
Example:
missing _;
data test ;
infile cards dsd firstobs=2 truncover ;
input @ ;
_infile_=tranwrd(cats(',',_infile_,','),',.,',',_,');
input @2 var1-var3 ;
cards;
var1,var2,var3
123,,456
.,789,012
;
proc print;
run;
Obs var1 var2 var3
1 123 . 456
2 _ 789 12
If you want the ._ values to print as * instead of _ then make your own format.
proc format ;
value star ._ = '*' ;
run;
proc print data=test;
format var1-var3 star5. ;
run;
... View more