Help using Base SAS procedures

Subsetting data

Reply
Occasional Contributor
Posts: 14

Subsetting data

I have two variables; the second dependent upon the answer of the first. There are 5 variables (Q1) each with its own severity scale (Q2).

Q1. Do you have the symptom? y/n/don't know/refused (1/2/88/99)

--> If a participant answered Y(1) to Q1, they should go to Q2.

Q2. Severity: 1/2/3/4/88/99

I would like to make a data set with no inappropriate missing data (where 'missing'=./don't know/refused).

So far, I have been able to subset my data for Q1:

data newdata;

     set olddata;

     if cmiss (of var1 var2 var3 var4 var5) then delete;

run;

This worked well and the expected number of observations were removed. However, I am unsure of how to move forward. If I ask SAS to remove the missing observations from Q2, then all those that answered N(2) to Q1 (and therefore, have appropriately missing data in Q2) would be removed. I only want to remove those individuals who answered Y(1) to Q1 and subsequently have missing data for Q2 (Q2 is conditioned on Q1).

Any direction would be appreciated.

Trusted Advisor
Posts: 1,204

Re: Subsetting data

How about this

data want;

     set newdata;

     if q1=1 and q2 in (88,99) then delete;

run;

Ask a Question
Discussion stats
  • 1 reply
  • 138 views
  • 0 likes
  • 2 in conversation