BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RandoDando
Pyrite | Level 9

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

 

 


 

View solution in original post

1 REPLY 1
Reeza
Super User

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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2085 views
  • 1 like
  • 2 in conversation