BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
stataq
Obsidian | Level 7

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  

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 233 views
  • 2 likes
  • 3 in conversation