BookmarkSubscribeRSS Feed
sambasiva_ravuri_tcs_com
Calcite | Level 5

Dear All,

I would like to write a program to read a file set all empty variables to missing values. Is it possible in SAS ?

Thanks a lot in advace for help and appreciate for the same.

Regards,

S Ravuri.

1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:

  I'm not sure what you mean when you says that you want to "read a file" and "set all empty variables to missing values". It is very possible in SAS to do what you ask, but the question is, what does your input file look like? Is it comma delimited, tab delimited, or a sequential file, such as created on the mainframe? Is it a file where all the daa is in fixed columns?

  How do you know that there are "empty variables" in the original input file?

  Can you post a sample of your data and the program that you have tried? For example, if you had a comma-separated file like this, with 3 variables and 4 rows, then:

  

"name","age","likes"

"Anna Marie",,chocolate

"Billy Bob",22,

,23,raspberry

"David",24,licorice

then, for the first data row (Anna Marie) does not have a value for AGE, so you could say that AGE is "empty" -- but SAS can correctly read the 2 commas next to each other as a missing value for AGE. Likewise, the 3rd data row -- for the 23 year old person who likes raspberry -- does not have any value for NAME. And, SAS can read this data and set name to missing (which will be represented as a blank for character variables).

Without knowing what your data looks like and what you mean by "empty", it is nearly impossible to make coding suggestions. Have you tried PROC IMPORT? Have you tried a DATA step program with an INFILE and INPUT statement?

cynthia

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 839 views
  • 0 likes
  • 2 in conversation