Date: Thu, 9 Nov 2006 16:35:34 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: find and drop empty variables
In-Reply-To: <7367b4e20611090815t51e0fa23te36cdbe53c34a496@mail.gmail.com>
Content-Type: text/plain; format=flowed
Data _Null_ ,
Yeah I forgot about that test case where all values are populated. As for
the formatting I hadnt thought about it but it does seem to speed the sucker
up. Nice bit of hinking there.
Toby Dunn
Quickly, bring me a beaker of wine, so that I may wet my mind and say
something clever.
Aristophanes
Wise people, even though all laws were abolished, would still lead the same
life.
Aristophanes
You should not decide until you have heard what both have to say.
Aristophanes
From: "data _null_;" <datanull@GMAIL.COM>
Reply-To: "data _null_;" <datanull@GMAIL.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: find and drop empty variables
Date: Thu, 9 Nov 2006 11:15:35 -0500
Your program almost works. It fails for variables that have no
missing values. Both of our methods performance can be significantly
improved with by formatting the variables. See below.
data work.test;
array _y[*] y1-y10;
array _c[*] $8 c1-c10;
do obs = 1 to 1e4;
id = put(obs,z10.);
do _n_ = 2 to dim(_y)-1;
_y[_n_] = ranuni(12345);
if abs(_y[_n_]) le .2 then _y[_n_] = .;
if abs(_y[_n_]) le .4
then _c[_n_] = ' ';
else _c[_n_] = put(_y[_n_],best8.);
end;
output;
end;
retain z .e e 'z';
run;
proc format; *cntlout=work.control;
value nmis .-.z =' ' other='1';
value $nmis ' '=' ' other='1';
run;
ODS Listing Close;
ODS Output OneWayFreqs=Freqs;(where=(frequency=cumfrequency));
Proc Freq Data=work.test;
Table _All_ / Missing;
format _numeric_ nmis. _character_ $nmis.;
run;
ODS Listing;
/*proc contents varnum;*/
/*proc print data=freqs;*/
/* run;*/
Data Missing;
Set Freqs;
if percent eq 100;
length var $32.;
Var = Scan(Table,-1,' ');
If missing(VValueX(Var));
format _all_;
keep var;
Run;
proc print;
run;
On 11/9/06, toby dunn <tobydunn@hotmail.com> wrote:
>Data One ;
>Infile Cards ;
>Input A B C $ D $ ;
>Cards ;
>1 . A .
>2 . B .
>3 . C .
>.. . D .
>5 . . .
>6 . F .
>;
>Run ;
>
>
>ODS Listing Close ;
>ODS Output OneWayFreqs = Freqs ;
>
>Proc Freq
> Data = One ;
> Table _All_ / Missing ;
>Run ;
>
>ODS Listing ;
>
>
>
>Data Missing ( Keep = Var ) ;
>Set Freqs ;
>Where Percent = 100 ;
>
>Var = Scan( Table , 2 , ' ' ) ;
>If ( InPut( VValueX( Var ) , 8. ) = . ) ;
>
>Run ;
>
>
>Proc SQL NoPrint ;
>Select Var Into : DropVars Separated By ' '
> From Missing ;
>Quit ;
>
>
>
>Data One ;
>Set One ( Drop = &DropVars ) ;
>Run ;
>
>
>
>
>
>Toby Dunn
>
>Quickly, bring me a beaker of wine, so that I may wet my mind and say
>something clever.
>Aristophanes
>
>Wise people, even though all laws were abolished, would still lead the same
>life.
>Aristophanes
>
>You should not decide until you have heard what both have to say.
>Aristophanes
>
>
>
>On 11/9/06, Alexander Norderwind <alexander_norderwind@yahoo.de> wrote:
> >I have the problem that a big database I import to SAS with proc sql and
> >ODBC has about thousand variables (fields) and lots of them are empty all
> >over.
> >Thus I would like dropping them to get rid of this ballast.
> >Therefore I first have to find out, which of them really are empty.
> >Does anybody have a suggestion how to solve my problem?
> >Would be nice!
> >Xander
> >
>
>_________________________________________________________________
>Stay in touch with old friends and meet new ones with Windows Live Spaces
>http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
>
>
_________________________________________________________________
Find a local pizza place, music store, museum and more…then map the best
route! http://local.live.com?FORM=MGA001
|