LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sun, 25 Aug 2002 10:51:40 -0400
Reply-To:   "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Organization:   MindSpring Enterprises
Subject:   Re: Is there any way to drop variables from a SAS dataset when all obs are missing?
Content-Type:   text/plain;

Know:

You will need to two-pass the data.

If there are no missing data in your data, you could read the first line to determine how many fields need to be read in for a given file.

If the first line (or any line) can having missing data, you will need to post process the data to drop your unwanted columns. There have been many previous threads on how to drop columns containing only missing values.

Richard A. DeVenezia http://www.devenezia.com/downloads/sas/macros/

"Know Spam" <NoSpam@nomail.com> wrote in message news:stpdmukk2n9j91q1dqj5e77nvfc08vgean@4ax.com... > Hi, some help if you can! > > I'm going to read from several hundred flat files, some will have only > 4 fields, some will have up to 125 fields. Because I don't have a way > to know how many fields in advance to read, I'm setting the input > statement to 125 possible using input x1-x125. > > This is a clumsy way to do it. Of course SAS will ignore variables in > an analysis with all missing observations, but it can be messy in the > output. > > In the example below, say that there are only 13 fields with data, so > I want this dataset to have only x1 to x13. > > File test002 may have 78 fields, so there will be x1-x78 in the > dataset that are all non-missing, x79 to 125 will be dropped. > > Is there a good way to do this? In my dreams, there's a SAS data > option such as: data one(if var=all missing, then drop); > > EXAMPLE: > > options macrogen mprint mlogic ; > %macro stats(file) ; > > data one ; > infile "D:\data\&file" missover pad ; > input var1-var125 ; > file = "&file" ; > run; > > %mend stats; > > %stats(test001.dat); > > Thanks! > KS


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