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 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 6 Aug 2008 20:09:48 -0400
Reply-To:   Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Subject:   Re: hundreds of variables, which variables have values over 1500
In-Reply-To:   <f7f6dd58-d91a-4998-83db-fe8120cb99f7@e39g2000hsf.googlegroups.com>
Content-Type:   text/plain; charset=ISO-8859-1

On Wed, Aug 6, 2008 at 4:54 PM, <jensen.emily@gmail.com> wrote:

> I have hundreds of files and each file has hunderds of variables. I > read them in using a pipe and macros. > > My problem is I need to see which variables have values over 1500. > How would I code it to look at all the variables in a certain file and > show me the variables that have values over 1500? > > Thanks > Emily >

The use of hash object very easily filters the variable names meeting the cut_value( in this case, 50).

%let fname = sashelp.class; %let cut_value = 50;

data _null_; length varname $ 32; if _n_ = 1 then do; declare hash h(); h.definekey('varname'); h.definedata('varname'); h.definedone(); end; do until(eof); set &fname end = eof; array k _numeric_; do over k; if k > &cut_value then do; varname = vname(k); if h.find() ne 0 then h.add(); end; end; end; h.output(dataset:"&fname." || '_Over' || "&cut_value"); stop; run;

Output of the dataset:

Obs varname

1 Weight 2 Height

This can be adapted to deal with a set of filenames as well as differing cut_values.

Muthia Kachirayan


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