| Date: | Sun, 12 Nov 2006 16:37:56 -0500 |
| Reply-To: | Don Henderson <donaldjhenderson@HOTMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
|
| From: | Don Henderson <donaldjhenderson@HOTMAIL.COM> |
| Subject: | Re: Separating alternate values macro list Wrong title (&&var&i) |
|
| In-Reply-To: | <200611122103.kACBjwoi010929@malibu.cc.uga.edu> |
| Content-Type: | text/plain; charset="us-ascii" |
Because you don't have a run statement after your proc print. So what you
intend to be the title for the next PROC PRINT is interpreted as the title
for the previous one.
You need to generate the statements inside your macro do loop as follows:
proc print . . . ;
title2 . . . . ;
run;
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Micotine Muso
> Sent: Sunday, November 12, 2006 4:04 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Separating alternate values macro list Wrong title (&&var&i)
>
> Hi,
>
> I am trying to write a dynamic code in a macro that separates out 1st,
> 3rd,
> 5th, .. and 2nd,4th,6th value from a list. I use %sysfunc(mod( for that. I
> made the program that works as desired but the title gives &&var&(i+1)
> rather than giving &&var&i.
>
> I am curious why this is happening and if there is a way around this.
>
> thanks for your feedback,
> Muso
>
> /***********************PROGRAM CODE BEGINS HERE **********************/
> /** DATA TAKEN FROM SAS UCLA ATS WEBSITE TO TEST THE WORKINGS OF MACRO */
> DATA auto ;
> LENGTH make $ 20 ;
> INPUT make $ 1-17 price mpg rep78 hdroom trunk weight length turn
> displ gratio foreign ;
> CARDS;
> AMC Concord 4099 22 3 2.5 11 2930 186 40 121 3.58 0
> BMW 320i 9735 25 4 2.5 12 2650 177 34 121 3.64 1
> Buick LeSabre 5788 18 3 4.0 21 3670 218 43 231 2.73 0
> Chev. Nova 3955 19 3 3.5 13 3430 197 43 250 2.56 0
> Datsun 200 6229 23 4 1.5 6 2370 170 35 119 3.89 1
> VW Rabbit 4697 25 4 3.0 15 1930 155 35 89 3.78 1
> VW Scirocco 6850 25 4 2.0 16 1990 156 36 97 3.78 1
> ;
> RUN;
>
> data _null_;
> set auto;
> %macro try;
> %let five=170 189 170 180 ;
> %do iii=1 %to 4;
> %if %sysfunc(mod(&iii,2)) eq 0 %then %do ;
> %let irt&iii=%scan(&five, &iii, %str( ));
> title2 "length<= &&irt&iii";
> proc print data=auto;where length<=&&irt&iii;
> %end;
> %end;
>
> %mend try;
> %try
|