Date: Sat, 24 Sep 2011 16:50:58 +0000
Reply-To: "DUELL, BOB" <bd9439@ATT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "DUELL, BOB" <bd9439@ATT.COM>
Subject: Re: When using length statement doesn't change format width
In-Reply-To: <201109241416.p8OAlEka009915@waikiki.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
Hi Art,
I don't know of any documentation that describes this behavior exactly as you describe, but it is expected. There are four different attributes associated with each SAS variable (LENGTH, FORMAT, INFORMAT, and LABEL) and each has a corresponding SAS statement that can be used to change the attribute. In other words, using the LENGTH statement only changes the length, it does not affect the other attributes.
For this reason, I almost always use the ATTRIB statement to define "production" SAS variables in each data set. The ATTRIB statement allows one to define all the attributes at once. For my very formal jobs (for each permanent SAS dataset going to a "production" library), I follow up the section of ATTRIB statements with a KEEP statement; although it does require a bunch of typing, it serves as very good in-code documentation. And the KEEP statement lets me use any other "temporary" variables in the code without them showing up in my production data.
I don't believe that using a LENGTH statement has ever simultaneously changed the variable format. Note that the FORMAT attribute is optional. My guess is that when you changed a variable length in the past and thought the format length had also changed, it was because the variable did not have any format specification to begin with. I could be wrong historically (perhaps it did so in a previous SAS release).
Hope this helps,
Bob
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Arthur Tabachneck
Sent: Saturday, September 24, 2011 7:16 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: When using length statement doesn't change format width
Can someone point me to documentation that talks about when using a length
statement, before a set statement in a data step, doesn't change the width of
the format statement?
My experience has always been that using a length statement to change the
width of a character variable results in simultaneously changing the width of
the format. However, I came across a case yesterday where that didn't hold.
Using a format statement, though, ended up changing both.
Is that particular behavior documented somewhere?
Thanks in advance,
Art
|