Frits Verstraten
Frits Verstraten

Reputation: 2179

Create two datasets in SAS output

I have the following dataset:

DATA survey; 
 INPUT id sex $ age inc r1 r2 r3 ; 
 DATALINES; 
 1  F  35 17  7 2 2 
 17  M  50 14  5 5 3 
 33  F  45  6  7 2 7 
 49  M  24 14  7 5 7 
 65  F  52  9  4 7 7 
 81  M  44 11  7 7 7 
 2   F  34 17  6 5 3 
 18  M  40 14  7 5 2 
 34  F  47  6  6 5 6 
 50  M  35 17  5 7 5 
 ;

Now I would like to create to files based on whether the records are Female (F)or NOT. Therefore I do this:

 date female other;

 set survey;

 if sex = "F" then output USA;
 else output other;
 run;


 PROC PRINT; RUN; 

This however does not give me two sets with data depending on the F and M value. Any idea on what I am doing wrong here?

Upvotes: 0

Views: 139

Answers (1)

Quentin
Quentin

Reputation: 6378

When you look in the log window, do you see any error messages?

If your code is

if sex = "F" then output USA;

you should see an error, because the DATA statement does not include a dataset named USA. If you change USA to FEMALE it should work.

Learning to read log messages is an essential skill in SAS.

Upvotes: 1

Related Questions