LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (February 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 1 Feb 2000 17:25:08 +0100
Reply-To:     BONNET Christophe <Christophe.BONNET@GEP.FR>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         BONNET Christophe <Christophe.BONNET@GEP.FR>
Subject:      Re: delete many variables
Comments: To: Hui Huang <huihuang@IUPUI.EDU>
Content-Type: text/plain; charset="iso-8859-1"

Here we are: one of my friend and I propose you what follows. It uses some sql and some macro-langage but it seems quite simple. The macro %deli will do what you want The first step uses a proc transpose, then you compute the mean and the std If mean=std=0 then your variable is all 0's.

The proc sql puts every "null" variable in a list Then you just have to drop these variables in the last step...

data a; input c1 c2 c3 c4; cards; 1 0 1 0 0 0 1 0 1 0 1 0 ; run;

%macro deli(data=);

proc transpose data=&data out=toto;

data toto; set toto; m=mean (of _numeric_); s= std( of _numeric_); if m=0; if s=0; keep _NAME_; run;

proc sql; select _name_ into :list separated by " " from toto; quit;

data a; set a; drop &list; run;

%mend deli;

proc print data=a;

%deli(data=a);

proc print data=a;

> ---------- > De : Hui Huang[SMTP:huihuang@IUPUI.EDU] > Répondre à : Hui Huang > Date : mardi 1 février 2000 16:21 > A : SAS-L@LISTSERV.UGA.EDU > Objet : delete many variables > > Hi all, > > Is there any way to delete many variables from a dataset? > For exampl dataset AAA looks like this: > > c1 c2 c2 c4 > 1 0 1 0 > 0 0 1 0 > 1 0 1 0 > > I want to delete variable c2 and c4 because every obs' value is 0 > for those variables. My point is how to delete some variables with all > values of obs in those variables 0's, but you don't know exactly which > variables have this property in advance, and therefore need to use some > sentences to do the judgement work? > > Any responses will be appreciated. > > Hui >


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