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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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