Date: Sun, 23 Mar 1997 13:30:39 GMT
Reply-To: Andreas Gr|ninger <100330.2642@COMPUSERVE.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Andreas Gr|ninger <100330.2642@COMPUSERVE.COM>
Organization: Unternehmensberatung Dr. Karb GmbH
Subject: Re: How can I drop columns with all missing values?
DATA test;
s2 = '>';
p2 = .;
s1 = '<';
DO p1=1 TO 100;
OUTPUT;
END;
RUN;
%MACRO m(dsname=,new=,
means=means,trans=trans,tempfil1=tempfil1);
FILENAME tempfil1 "&tempfil1";
* --- calculate freqencies of Pn;
PROC MEANS DATA=&dsname NOPRINT MISSING;
OUTPUT OUT=&means (DROP=_type_ _freq_) N=;
RUN;
* --- transpose the output in well-suited form ;
PROC TRANSPOSE DATA=&means OUT=&trans NAME=var PREFIX=nobs;
RUN;
* --- create a sas program with a drop statement for the
variables Pn with frequencies=0 ;
DATA _null_;
LENGTH n $8;
SET &trans (WHERE=(nobs1=0)) END=last;
FILE tempfil1;
IF (_n_=1) THEN
PUT "DATA &new;"
/ " SET &dsname;"
/ " DROP";
n = SUBSTR(var,2);
PUT +3 var 's' n;
IF (last) THEN
PUT " ;"
/ "RUN;";
RUN;
%INCLUDE tempfil1;
FILENAME tempfil1 CLEAR;
%MEND;
%m (dsname=test,new=a);
--
Andreas Gr|ninger
Unternehmensberatung Dr. Karb
Im Wolfer 10
70599 Stuttgart
EMail: 100330.2642@compuserve.com
Paul Robins <paul.robins@st.com> schrieb im Beitrag
<3332DBD5.3FF5@st.com>...
> I have datasets with pairs of columns, each pair representing a
> measurement. The first in each pair is a numeric result, the second
> is a character code representing the status of the result, i.e.
> '>' represents 'above high validity limit', '<' represents 'below low
> validity limit', etc.
>
> The pairs of columns are named Pn Sn, where 'n' is a common
> numeric value. The 'P' column being the measurement and the 'S' being
> the status.
>
> The datasets may have several hundred columns and several thousand rows.
> I'm using version 6.11 on UNIX.
>
> For many of the pairs of columns I have all missing values in the
> 'P' column. In these cases I would like to drop both columns in the
> pair.
>
> any ideas? I'd prefer a solution in base SAS code if possible, but
> I'm open to all suggestions.
>
> Thanks
>
> Paul Robins.
>