Date: Sun, 18 Dec 2005 18:26:54 -0700
Reply-To: "Navabi, Alireza" <Alireza.Navabi@AFHE.UALBERTA.CA>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Navabi, Alireza" <Alireza.Navabi@AFHE.UALBERTA.CA>
Subject: Re: Need help on a simple data manipulation question
Content-Type: text/plain; charset="iso-8859-1"
Jason,
Use "drop" statement.
drop y2 y3 y5;
Alireza
________________________________
From: SAS(r) Discussion on behalf of Jason Shen
Sent: Sun 18/12/2005 5:25 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Need help on a simple data manipulation question
Hi,
I need help on a simple data manipulation question. For example, I have the following data set.
data test;
input x y1 y2 y3 y4 y5;
cards;
1 3 * 5 90 9
1 2 * 9 10 *
1 2 * 8 8 6
2 1 3 * 8 10
2 3 8 * * 9
2 4 2 * 9 3
3 9 2 9 4 *
3 8 1 2 5 *
;
If any one of variables y1-y5 does not have any non-missing values for each value of x, this variables should be removed from the dataset. So in this case, y2 is all missing for x=1; y3 is all missing for x=2 and y5 is all missing for x=3. I want to remove variables y2, y3 and y5 from the data set. Since I actually have 50 variables in my real data, I want to know how to write the code to remove the variables I don't want.
the final data shoud look like this:
1 3 90
1 2 10
1 2 8
2 1 8
2 3 *
2 4 9
3 9 4
3 8 5
Thanks a lot.
Jason
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|