I am importing a CSV file which has blank values in a numeric field. The blanks are in delimited file as simply two sequential commas. I want to read those as . but SAS is skipping over them. I tried the MISSOVER option but it is still going to the next variable. The variable with the missing values is "Rate". It is in the CSV file as percents (with the % signs), so I had to specify the :percent. format option then change it to Percent10.2 after the import. I want blanks to be imported as blanks (which is . for numeric data).
data one;
infile "\\...MyFile.csv" dlm=',' firstobs=2 missover ;
length state county $24;
input State $ County $ FIPS Population Total rate :percent. score ;
rename county = county_name;
format rate Percent10.2;
run;
Try the DSD option and TRUNCOVER.
infile "\\...MyFile.csv" DSD firstobs=2 TRUNCOVER;
For your percent you may want an informat instead.
length state county $24;
informat rate percent.;
input State $ County $ FIPS Population Total rate score ;
@RandoDando wrote:
I am importing a CSV file which has blank values in a numeric field. The blanks are in delimited file as simply two sequential commas. I want to read those as . but SAS is skipping over them. I tried the MISSOVER option but it is still going to the next variable. The variable with the missing values is "Rate". It is in the CSV file as percents (with the % signs), so I had to specify the :percent. format option then change it to Percent10.2 after the import. I want blanks to be imported as blanks (which is . for numeric data).
data one; infile "\\...MyFile.csv" dlm=',' firstobs=2 missover ; length state county $24; input State $ County $ FIPS Population Total rate :percent. score ; rename county = county_name; format rate Percent10.2; run;
Try the DSD option and TRUNCOVER.
infile "\\...MyFile.csv" DSD firstobs=2 TRUNCOVER;
For your percent you may want an informat instead.
length state county $24;
informat rate percent.;
input State $ County $ FIPS Population Total rate score ;
@RandoDando wrote:
I am importing a CSV file which has blank values in a numeric field. The blanks are in delimited file as simply two sequential commas. I want to read those as . but SAS is skipping over them. I tried the MISSOVER option but it is still going to the next variable. The variable with the missing values is "Rate". It is in the CSV file as percents (with the % signs), so I had to specify the :percent. format option then change it to Percent10.2 after the import. I want blanks to be imported as blanks (which is . for numeric data).
data one; infile "\\...MyFile.csv" dlm=',' firstobs=2 missover ; length state county $24; input State $ County $ FIPS Population Total rate :percent. score ; rename county = county_name; format rate Percent10.2; run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.