Date: Thu, 19 Jan 2006 02:56:09 -0500
Reply-To: "SASsy :-)" <sas__l@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "SASsy :-)" <sas__l@HOTMAIL.COM>
Subject: Re: Macro to handle changing column names?
On Wed, 18 Jan 2006 23:37:05 -0500, Brian Bachman <bsquared@CTC.NET> wrote:
If you know their positions for sure, then you can get the variable names
into macro variables with a snippet like this
(here vars 1 to 6..) :
%macro varnames (ds= );
%do i=1 %to 6;
%let var&i = %sysfunc(varname(&dsid ,&i));
input var1_200502 var1_200503 var1_200504 var2_200502 var2_200503
and then use these in your equation.. will that work?
>Sorry to place this here but after searching the archives I couldn't find
>what I was looking for. (I suspect I wasn't describing it correctly).
>My problem is this. I have a data set that has year and month as part of
>column name (eg. Var1_200501 var1_200502, etc...) There are many columns
>like this and six unique year/month combinations associated with these. A
>new data set is generated every month and the year/month suffix will
>Now. I have an equation of a familiar form y= int +
>var2_200504)+... I guess I am asking for help in identifying a simple
>strategy for creating an association between the columns required for my
>equation given that the actual column suffixes will change but be in a
>predictable sequence every time a new data set is presented. For example if
>presented with var1_200510 var1_200511 var1_200512 var1_200601
>var1_200602 var1_200603, the program should be able to automatically equate
>these variables to the positions originally occupied by variables
>Is this at all clear? My macro skills have really gone to pot in the past
>few years and am hoping that someone can point me in the right direction.
>TIA and best regards,