LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
In-Reply-To:  <744ec0710910060936x565bd57eg527dd3c771a6d597@mail.gmail.com>
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:

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=' '); run;

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 blank.

I tried an array but I can't get it to work.

Any suggestions?

On Tue, Oct 6, 2009 at 12:36 PM, Theresa Roman <troman.sas@gmail.com> wrote:

> Hello, > > 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=' '); > run; > > > so basically if q13 is 2 or 3, Q13s can't be left blank same idea with > Q14-Q18. > > So I want data set "check' to have only those variables where this is the > case. > 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? > > Thanks, > > Tere >


Back to: Top of message | Previous page | Main SAS-L page