Date: Thu, 20 Dec 2007 09:04:48 -0500
Reply-To: Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject: Re: How to extract unary variables from a dataset automately?
Content-Type: text/plain; charset="us-ascii"
I assume that by "unary" you mean all variables that have the same value
for each record.
For numeric variables, I would use PROC SUMMARY -- get and transpose an
output data set, then check to see whether the MIN and MAX are the same
(with an extra check or two if you have missing values to contend with).
AllMissing = .;
UnaryVar = 111;
UnaryVarPartMissing = UnaryVar;
AgePartMissing = Age;
if _N_ = 1 then do;
UnaryVarPartMissing = .;
AgePartMissing = .;
proc summary data=newclass;
output out=summout (drop=_TYPE_);
proc transpose data=summout (drop=_FREQ_) out=transout;
proc sql noprint;
select _NAME_ into :UnaryVarList separated by ' '
from transout, summout (keep=_FREQ_ _STAT_ where=(_STAT_='N'))
where min = max and
/* Either all missing values or no missing values */
(n = 0 OR n = _FREQ_)
%PUT Unary variables: &UnaryVarList;
From: firstname.lastname@example.org [mailto:email@example.com]
On Behalf Of Hu Yang
Sent: Wednesday, December 19, 2007 6:16 PM
Subject: How to extract unary variables from a dataset automately?
I want to get rid of the unary variables in a very large dataset.
One idea is to use proc freq. But if the dataset is large and contains
many variables such as 3000, the method would be very slow. Is there an
efficient way (both in time and space) to automately extract the unary
variables' name into a macro variable?
Thanks a lot!