BookmarkSubscribeRSS Feed
GVeers
Calcite | Level 5
Hey all, I have an Access database that with a number of fields that use "-9999" as a "missing" value. I am going to read the data into SAS using Proc Import (I'm slightly scared of other methods) and then use a Data statement to translate the -9999 to the missing character.

This seems like a clunky way to do things, particularly with the sheer number of variables that are set up in this fashion. Is this the best way to do it, or is there another way (maybe ditch the Proc Import or streamline the Data statement)?

Thank you very much in advance for any help you can offer.
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Here is some DATA step code to consider using, an explicit array to address numeric variables only:

ARRAY a_num (*) _numeric_;
do i=1 to dim(a_num);
if = -999 then = .;
end;

Scott Barry
SBBWorks, Inc.
GVeers
Calcite | Level 5
I see. Thank you very much for the reply.
ChrisNZ
Tourmaline | Level 20
you can use Scott's code this way:

ARRAY a_num (*) _numeric_;
do i=1 to dim(a_num);
if a_num(i) = -9999 then a_num(i) = .;
end;

and all numeric variables are handled automatically without your having to name them.
ballardw
Super User
I would seriously look into creating one or more INFORMATS using Proc Format and INVALUE.

Something like this would set all values less than 0 to missing. The only issue is assigning the informat while using Proc Import. (Hint the log should contain a bunch of INFORMAT, FORMAT statements after the first run. Copy the code from the Log to the editor and apply as needed)

Proc format;
invalue groupval 0- high= _same_
other= .;
run;

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 981 views
  • 0 likes
  • 4 in conversation