Date: Wed, 22 Aug 2007 10:40:45 -0400
Reply-To: "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (CDC/CCHIS/NCPHI)" <rjf2@CDC.GOV>
Subject: Re: Questions on appending numerous datasets...
In-Reply-To: <1187792286.976076.41080@q4g2000prc.googlegroups.com>
Content-Type: text/plain; charset=us-ascii
> From: wardnine
>
> I have a folder on my computer that contains 50 datasets...
> each dataset contains data for one of the 50 states in the
> country and are named accordingly using the state
> abbreviation (e.g., Alabama dataset name is aldata, Georgia
> dataset name is gadata, Wyoming data set name is wydata,
> etc.). I was looking for a quick way to merge all 50 datasets
> into one dataset without having to write out the name for
> each dataset? All 50 datasets have the same exact variables,
> so I know I can just use the set statement to combine them
> all, but was looking for a way to do it without having to
> list out each of the 50 datasets.
> Is there code that lets you combine/append all datasets
> within a given folder? Alternatively (and perhaps more
> efficiently), is there code that would let me combine the 50
> datasets together given that the naming convention for all of
> the datasets is the same (perhaps using arrays and macros)?
> Thanks for any advice you can give here!
%Let LibName = States;
libname &LibName. '<directory-specification>';
%Let List = *ooops!;
PROC SQL; select catx('Proc Append base =Library.AllStates data='
,LibName
,'.'
,MemName
,';'
)
into :List
from Dictionary.Tables
where LibName eq "&LibName.";
quit;
&List.;
run;
Ron Fehd the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov
see also:
sgf2007.113:
List Processing Basics:
Creating and Using Lists of Macro Variables
Ronald J. Fehd, and Art Carpenter
http://www2.sas.com/proceedings/forum2007/113-2007.pdf
|