|
Hi Bill,
Have a look at my macro DropMV that removes all variables with missing
values. It has been discussed before, see:
http://listserv.uga.edu/cgi-bin/wa?S2=sas-l&D=1&H=0&O=D&T=1&q=dropmv&s=&f=jim&a=&b=
Regards - Jim.
--
Jim Groeneveld, Netherlands
Statistician, SAS consultant
http://jim.groeneveld.eu.tf
On Mon, 12 Apr 2010 18:54:34 -0400, William Krause <wkrause2003@YAHOO.COM>
wrote:
>I have a dataset that contains 5000 rows but contains around 20,000
>variables. The variable name are too large to fit into a macro variable
>(exceeds the max length).
>
>How can I find all the variables which contain only missing values (blanks
>for character variables) and (. for numeric variables).
>
>I have some code from somewhere that uses a macro variable but it only
>works within the macro length limits.
>
>This is the code I used -- doesn't work for large variable lists.
>
>All I'm concerned with is identifying the variables that contain values
>that are all blank.
>
>**** Finding and Dropping Emtpy Variables that contain all blank/missing
>values. ******* ;
>options symbolgen;
>
>data class;
> set sashelp.class;
>name=' ';
>ndummy=.;
>cdummy=' ';
>
>proc sql noprint;
> select 'case when nmiss('||compress(name)||')=count(*) then "'
> ||compress(name)||'" else " " end' into :nlst separated by "||' '||"
> from dictionary.columns
>where libname='WORK' and memname='CLASS'
>;
>select distinct &nlst
>into :droplst
>from class
>;
>
>data class;
> set class;
> drop &droplst;
>run;
>
>proc print;
>run;
>
>I had modified the program above to write out the cases statements to a
>external file. I modified it but I couldn't get it to work either.
>I put a statements in the external dataset:
>proc sql ;
>create table blnkmrv as
>
>Also removed the comma from the end of the last case statement.
>
>libname blnk " C:\MYDATA" ;
>proc sql noprint;
> CREATE TABLE BLNK_CASES AS
> select 'case when nmiss('||compress(name)||')=count(*) then "'
> ||compress(name)||'" else " " end' || ','
> from dictionary.columns
> where libname='BLNK' and memname='MYCASES'
>;
>quit ;
>
>FILENAME TMP "C:\TEMP\BLNKDATA.SAS" ;
>DATA _NULL_ ;
> SET BLNK_CASES ;
> FILE TMP ;
> PUT _TEMA001 ;
>RUN ;
>
>
>PROC SQL ;
> %INCLUDE TMP
>;
>QUIT ;
>
>
>You can ignore the code above.
>
>All I need I a solution that will process the 20000 variables.
>
>Thanks for you assistance.
>
>Bill K.
>wkrause2003@yahoo.com
|