- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I would like to create a dummy dataset as below:
id | sex | stop |
1 | Female | 0 |
1 | F | 1 |
1 | Male | 0 |
1 | M | 0 |
1 | 1 |
My codes are like below:
data df ;
infile datalines missover;
input id sex $ stop;
datalines ;
1 Femal 0
1 M 1
1 Male 0
1 F 0
1 1
;
run;
However it came out like below which is wrong. What did I do wrong. How can I create the dataset contain missing value?
id | sex | stop |
1 | Female | 0 |
1 | F | 1 |
1 | Male | 0 |
1 | M | 0 |
1 | 1 |
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Put a period for the missing value (both numeric and character variables).
data df ;
infile datalines truncover;
input id sex $ stop;
datalines ;
1 Femal 0
1 M 1
1 Male 0
1 F 0
1 . 1
;
Note you almost never want the functionality of the ancient MISSOVER option, which will set values missing when the line is too short for the informat being used. So use the modern (less than 40 years old) TRUNCOVER option instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Put a period for the missing value (both numeric and character variables).
data df ;
infile datalines truncover;
input id sex $ stop;
datalines ;
1 Femal 0
1 M 1
1 Male 0
1 F 0
1 . 1
;
Note you almost never want the functionality of the ancient MISSOVER option, which will set values missing when the line is too short for the informat being used. So use the modern (less than 40 years old) TRUNCOVER option instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the DSD option and a proper delimiter:
data df;
infile datalines dsd truncover;
input id sex $ stop;
datalines;
1,Female,0
1,M,1
1,Male,0
1,F,0
1,,1
;