'Converting values to a character missing value in SAS
Hi I am having trouble with this question related to a school project. Converting values to a character missing value.
Run the following program to create the Dataset NOTAPPLY.
DATA NOTAPPLY;
LENGTH A B C D E $ 2;
INPUT ID A $ B $ C $ D $ E $ X Y Z;
DATALINES;
001 Y N N Y Y 1 2 3
002 na NA Y Y Y 3 4 5
003 NA NA NA na na 8 9 10
;
In the SAS data set NOTAPPLY, a value of either NA or na was used in place of a missing value for all character variables. Create a new SAS data set NEW where these values are converted to a character missing value.
Solution 1:[1]
There are many ways of converting values in SAS. One of them is using an INFORMAT by importing data. So you code might look like:
proc format;
invalue $MYMISS
'NA'=' '
'na'=' '
;
run;
DATA NEW;
LENGTH A B C D E $ 2;
INPUT ID A:$MYMISS2. B:$MYMISS2. C:$MYMISS2. D:$MYMISS2. E:$MYMISS2. X Y Z;
DATALINES;
001 Y N N Y Y 1 2 3
002 na NA Y Y Y 3 4 5
003 NA NA NA na na 8 9 10
;
run;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Egor Lipchinskiy |
