- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 08-11-2009 05:34 PM
(2518 views)
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.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
ARRAY a_num (*) _numeric_;
do i=1 to dim(a_num);
if
end;
Scott Barry
SBBWorks, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I see. Thank you very much for the reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
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;