Date: Tue, 6 Oct 2009 13:36:43 -0400
Reply-To: Theresa Roman <troman.sas@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Theresa Roman <troman.sas@GMAIL.COM>
Subject: Re: I want to drop a specific variable with a specific value
Content-Type: text/plain; charset=ISO-8859-1
Thank you all for your input.
That makes sense...so what if I tell you that I can split the file in a way
that I get a single observation, i.e. a single row.
How can i ask SAS to let me keep only those variables for which Qi is in
(2,3) and Qis =' ' ?
So i run this code:
If (Q13 in (2,3) and Q13s=' ') or (Q14 in (2,3) and Q14s=' ') or (Q15 in
(2,3) and Q15s=' ') or (Q16 in (2,3) and Q16s=' ') or (Q17 in (2,3) and
Q17s=' ') or (Q18 in (2,3) and Q18s=' ');
then I have already set up a macro that splits the above data set check by
observation. So if the above set has 5 observations with this split macro i
get five different data sets.
This new five data sets still contain 3 variables UNIQUE ID, Q13-Q18 and
Q13s-Q18s. Now, how do I ask SAS to get rid off those variables for which qi
is not in (2,3) and Q1s =blank.
and I want to drop both Qi and Qis if this is true. So the final set will be
a single obs (single row) with variables where Qi is in (2,3) and Qis is
I tried an array but I can't get it to work.
On Tue, Oct 6, 2009 at 12:36 PM, Theresa Roman <email@example.com> wrote:
> Any suggestions will be greatly appreciated.
> Nature of the dataset: 13 variables UNIQUE ID, Q13-Q18 and Q13s-Q18s
> Goal: logic check.
> Possible values of Q12-Q18 are 1, 2, or 3.
> Q13s-Q18s are character variables
> Here is what i have so far:
> data check;
> set form1;
> If (Q13 in (2,3) and Q13s=' ') or (Q14 in (2,3) and Q14s=' ') or (Q15 in
> (2,3) and Q15s=' ') or (Q16 in (2,3) and Q16s=' ') or (Q17 in (2,3) and
> Q17s=' ') or (Q18 in (2,3) and Q18s=' ');
> so basically if q13 is 2 or 3, Q13s can't be left blank same idea with
> So I want data set "check' to have only those variables where this is the
> However, using the code above, I am getting all 12 variables again. So if
> at least for one question from Q13-Q18 this is true I get all the variables.
> Does that make sense?
> I don't want that. I only want the variables where Qi is in 2,3 and Qis is
> blank to show, nothing else. where i is 13 to 18.
> Any suggestions?