Date: Mon, 3 May 1999 21:15:53 -0400
Reply-To: Richard DeVenezia <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Richard DeVenezia <radevenz@IX.NETCOM.COM>
Organization: Netcom
Subject: Re: More SAS rats.
There is a call routine to obtain the label of a variable.
CALL LABEL (var1, var2) where var1's value is a data set variable name and
var2 is the label of that variable.
Unfortunately, there is none to set the label.
A good topic (probably already been suggested) for the SAS ballot is to have
call getlabel
call setlabel
or even better
call getheader (<var>, <item>, <itemvalue>);
call setheader (<var>, <item>, <itemvalue>);
where <item> is label, length, format, informat (i.e. anything attrib can
do). Length would be tricky, but I am sure an appropriate set of rules
could be constructed.
Lambert, Bob wrote in message
<851200E65752D211BC89006008CE53537770C7@Z9999021.core.afcc.com>...
>Ignoring the ill effects of arrays on SAS Rats for the moment, I have a
>question on said toxins.
>
>I tried formatting array variables with the statement:
>---format ans(i) pct.;---
>Likewise, label statements (label ans(i)="....") also fail.
>
>I then elicited the help of macros. This worked. However, when I tried to
>replace:
>---do i=1 to dim(numer)----
>with
>---%do i=1 %to %sysfunc(dim(numer))---
>I found out that the dim function is one of a handful that can't be used
>with %sysfunc.
>Thus I had to resort to call symput.
>
>My question---> Is there a simpler way to specify formats and labels on
>array vars?
>Also--> if one doesn't know the macro language, what options exist to
>accomplish these tasks?
>
>REF CODE BELOW:
>***************************************************************************
*
>*****************;
>
> proc format;
> picture pct (round default = 7)
> 0= " "
> other = "009.9%" ;
> run;
>
>*** Note: I'll thank UPOLEW1@WESTAT.COM and Dr. Whittington at this time
for
>the pct. format. ****;
>*** (UPOLEW1@WESTAT.COM answered a question posted by Dr. Whittington a
>while back.) ****;
>
>%macro deer;
>
> data accts;
> array numer(*) m1-m17;
> array ans(17);
> call symput('f',dim(numer));
>
> set accts;
>
> %do i=1 %to &f;
> ans(&i)=100*numer(&i)/_freq_;
> label ans&i="% after &i Months";
> format ans&i pct.;
> %end;
>
> drop m1-m17;
>
> run;
>
>%mend;
>
>%deer;
>
>****************** data set "accts"
>************************************************;
>
>
>
>OBS FILENAM _FREQ_ M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12 M13 M14 M15
>M16 M17
>
> 1 APR98 201 0 0 0 4 9 13 8 32 36 38 40 0 0 0 0
>0 0
> 2 AUG98 376 0 0 6 4 8 20 7 0 0 0 0 0 0 0 0
>0 0
> 3 DEC97 244 0 0 1 3 6 8 0 26 29 33 33 37 38 39 39
>0 0
> 4 DEC98 259 0 1 5 0 0 0 0 0 0 0 0 0 0 0 0
>0 0
> 5 FEB99 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>0 0
> 6 JAN98 129 0 0 0 0 1 1 3 9 10 10 11 11 11 13 0
>0 0
> 7 JAN99 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>0 0
> 8 JUL98 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>0 0
> 9 JUN98 21 0 0 1 1 1 1 1 2 3 0 0 0 0 0 0
>0 0
> 10 MAR99 236 . . . . . . . . . . . . . . .
>. .
> 11 MAY98 219 0 0 0 2 3 6 7 17 18 18 0 0 0 0 0
>0 0
> 12 NOV97 156 0 0 2 4 6 7 0 14 15 16 16 18 18 21 22
>24 0
> 13 NOV98 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>0 0
> 14 OCT97 149 0 0 0 3 5 6 7 9 11 12 13 15 15 16 17
>18 18
> 15 OCT98 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>0 0
> 16 SEP98 435 0 0 2 5 9 15 0 0 0 0 0 0 0 0 0
>0 0
>
>
>Bob Lambert
>Associates capital Bank
|