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 (November 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 27 Nov 2007 18:42:53 -0500
Reply-To:   Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:   Re: Instead Hard code to create a macro
Comments:   To: vijay_sas@HOTMAIL.COM

Vijay,

Since no one has responded, I may have misundertood what you are looking for. The following, very untested code, does what I think you were asking the list how to do.

If it is, let the list know, and I'm sure that some of our better coders can simplify/correct/improve the methods which could be used:

%let number_of_records=20; %let number_of_variables= %sysfunc(putn(29*&number_of_records.,3.)); data master1 ; infile 'C:\averages.csv' dlm=',' dsd flowover firstobs=2; array av{&number_of_records.,29}; input v1-v&number_of_variables.; drop av:; do z=1 to lastrec by 1; set sasuser.tempfinal_append point=z nobs=lastrec; a=&number_of_records.-k+1; b=j+3; c=&number_of_records.-k1+1; d=j1+3; x1m1=av(a,b); x2m1=av(c,d); x1m2=av(a-1,b); x2m2=av(a-1,d); x1m3=av(a-2,b); x2m3=av(a-2,d); drop a b I Y _MODEL_ _TYPE_ _DEPVAR_ _IN_ _P_ _EDF_ C D; output; end; run;

Art --------- On Sun, 25 Nov 2007 21:04:46 -0800, vj <vijay_sas@HOTMAIL.COM> wrote:

>Hi, >Can anybody suggest me to create a macro for this program? >This code creates 3 months forecast x1m1,x1m2,x1m3. >This program created with a hardcode commented below array >av{20,29}; and a=20-k+1; and >c=20-k1+1; >Has read 20 (months)observations and 29 columns mentioned in array >statement. If months increases 21 or may be 25 I have to change. So I >don't want to write the hard code. Instead I should create a macro. > > >Any SAS guru's give the solution? > >data master1 ; >infile 'C:\averages.csv' dlm=',' dsd missover firstobs=2; >array av{20,29}; /************* hard code*****************/ >input av1-av29 / av30 - av58/av59 - av87 / av88 - av116/av117 - av145/ >av146 - av174 / >av175 - av203 / av204 - av232 / av233 - av261 / av262 -av290 / av291 - >av319 / av320 - av348 / >av349 - av377 / av378 - av406 / av407 - av435 / av436 - av464 / av465 >- av493 / av494 - av522 / >av523 - av551/av552 - av580; >drop av1-av580; >do z=1 to lastrec by 1; >set sasuser.tempfinal_append point=z nobs=lastrec; >a=20-k+1; /*********** hard code****************/ >b=j+3; >c=20-k1+1; /*********** hard code****************/ > >d=j1+3; >x1m1=av(a,b); >x2m1=av(c,d); >x1m2=av(a-1,b); >x2m2=av(a-1,d); >x1m3=av(a-2,b); >x2m3=av(a-2,d); >drop a b I Y _MODEL_ _TYPE_ _DEPVAR_ _IN_ _P_ _EDF_ C D; >output; >end; >run; > > >Thanks much in Advance. > >Vj


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