Date: Fri, 29 Oct 2010 09:37:45 -0400
Reply-To: "Fehd, Ronald J. (CDC/OCOO/ITSO)" <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (CDC/OCOO/ITSO)" <rjf2@CDC.GOV>
Subject: FW: How can i take columns dynamically
Content-Type: text/plain; charset=us-ascii
> From: Joe H. Smith
> Sent: Friday, October 29, 2010 5:59 AM
> Subject: How can i take columns dynamically
>
> Hi,
> I have a report its presenting last 6 months business data for example
>
> Apr May Jun Jul Aug Sep
> 1 2 3 4 5 6
> 5 3 4 6 2 3
>
> In next month when i generate report it should add Oct month and data
> and
> hidden Apr month it means the report contains always last 6months from
> execution date, so how can i take data like that dynamically
> your task will be simplified by an order of magnitude
> if you name your variables:
> attrib
> mon01 length = 4 label = 'Jan'
> mon02 length = 4 label = 'Feb'
> ...
> mon12 length = 4 label = 'Dec'
> ;
one solution is an associative array
this is a hard-coded example
get this working before you attempt a dynamic solution:
%Put SysDate: &SysDate.;
%Put mm : %sysfunc(month(%sysfunc(date())));
%Let mm = %sysfunc(month(%sysfunc(date())));
%Let Rpt01 = mm10 mm11 mm12 mm01;
%Let Rpt02 = mm10 mm11 mm12 mm01 mm02;
*...;
%Let Rpt10 = mm04 mm05 mm06 mm07 mm08 mm09 mm10 ;
%Put Rptrange: &&Rpt&MM.;
PROC Report data = Library.MyCumulativeSnapshot;
variables &&Rpt&MM.;
Ron Fehd the naming-conventions maven