Date: Fri, 17 Feb 2012 08:25:45 -0600
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Assign Labels to Variables When Referencing Them by Array
Elements
In-Reply-To: <456B52C41B724C41B96561D7AD283E7D01F0564A@mail.chpdm.umbc.edu>
Content-Type: text/plain; charset=ISO-8859-1
ATTRIB is not executable.
You cannot use array name as a variable list in an ATTRIB. You can
use other types of "SAS Variable Lists".
data test;
jan = "X2";
feb = "X2";
mar = "X1";
run;
data test2;
set test;
array v (3) jan feb mar;
attrib _all_ label="Monthly Coverage Group";
x = 3;
run;
proc contents;
run;
On 2/17/12, Jack Clark <jclark@hilltop.umbc.edu> wrote:
> Hello,
>
>
> I have variables which are monthly coverage groups. I have them defined
> in an array, and I am processing them in a DO loop. One thing I would
> like to do is add a LABEL to each variable, and the label value is the
> same for each variable. I am trying to think of a way to do this in the
> DO loop, but I am not having success. Both attempts below did not work.
>
>
>
> data test;
>
> jan = "X2";
>
> feb = "X2";
>
> mar = "X1";
>
> run;
>
>
>
>
>
> data test2;
>
> set test;
>
> array v (3) jan feb mar;
>
>
>
> do i = 1 to 3;
>
> *label v(i) = "Monthly Coverage Group";
>
> attrib vname(v(i)) label = "Monthly Coverage Group";
>
> end;
>
> run;
>
>
>
> 119
>
> 120
>
> 121 data test2;
>
> 122 set test;
>
> 123 array v (3) jan feb mar;
>
> 124
>
> 125 do i = 1 to 3;
>
> 126 *label v(i) = "Monthly Coverage Group";
>
> 127 attrib vname(v(i)) label = "Monthly Coverage Group";
>
> -
>
> 22
>
> 76
>
> ERROR 22-322: Syntax error, expecting one of the following: a name, -,
> :, FORMAT, INFORMAT,
>
> LABEL, LABLE, LENGTH, TRANSCODE, _ALL_, _CHARACTER_,
> _CHAR_, _NUMERIC_.
>
>
>
> ERROR 76-322: Syntax error, statement will be ignored.
>
>
>
> 128 end;
>
> 129 run;
>
>
>
> NOTE: The SAS System stopped processing this step because of errors.
>
> WARNING: The data set WORK.TEST2 may be incomplete. When this step was
> stopped there were 0
>
> observations and 4 variables.
>
> WARNING: Data set WORK.TEST2 was not replaced because this step was
> stopped.
>
> NOTE: DATA statement used (Total process time):
>
> real time 0.00 seconds
>
> cpu time 0.00
>
>
>
>
>
>
>
>
>
> I could also put all of the variables in a single ATTRIB statement
> outside the DO loop, but would need a way to reference all the variables
> in the array
>
>
>
> ATTRIB (some way to reference all variables in array) LABEL = "Monthly
> Coverage Group";
>
>
>
> Any ideas? Thanks.
>
>
>
> Jack
>
>
>
> Jack Clark
> Senior Programmer
> phone: 410-455-6256
> fax: 410-455-6850
> jclark@hilltop.umbc.edu
>
> University of Maryland, Baltimore County
> Sondheim Hall, 3rd Floor
> 1000 Hilltop Circle
> Baltimore, MD 21250
>
> Please consider the environment before printing this e-mail and/or any
> attachments.
>
>
> Confidentiality Notice: This e-mail may contain information that is legally
> privileged and that is intended only for the use of the addressee(s) named
> above. If you are not the intended recipient, you are hereby notified that
> any disclosure, copying of this e-mail, distribution, or action taken in
> reliance on the contents of this e-mail and/or documents attributed to this
> e-mail is strictly prohibited. If you have received this information in
> error, please notify the sender immediately by phone and delete this entire
> e-mail. Thank you.
>
|