| Date: | Fri, 4 Jul 2008 12:28:40 +0530 |
| Reply-To: | Anindya Mozumdar <anindya.lugbang@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Anindya Mozumdar <anindya.lugbang@GMAIL.COM> |
| Subject: | Re: Proc SQL- use of "as" brings along the old label! |
|
| In-Reply-To: | <bb6e8a8b-cffa-4a2e-90f9-d0d53723e81c@z24g2000prf.googlegroups.com> |
| Content-Type: | text/plain; charset=ISO-8859-1 |
You can also use
select old_var as new_var label="mylabel"
I suspect this will be more efficient while processing, but the code
will not be portable.
Anindya
On Fri, Jul 4, 2008 at 1:44 AM, Angel <norcalangel@gmail.com> wrote:
> Great timing on this post. I just came across that problem myself
> Thank you for the quick fix. Worked perfectly.
>
> -Angel
>
> On Jul 1, 12:09 pm, ya.hu...@AMYLIN.COM (Ya Huang) wrote:
>> This has been discussed before. Here is a quick fix:
>>
>> select old_var+0 as new_var /* for numeric var */
>> or
>> select old_var||'' as new_var /* for character var */
>>
>> On Tue, 1 Jul 2008 13:28:17 -0500, Mary <mlhow...@AVALON.NET> wrote:
>> >I just ran across an unexpected result in Proc SQL; if I attempt to use
>>
>> the "as" to create a new name, then if there is a label attached to it, it
>> retains the old label! Example:
>>
>>
>>
>> >data test;
>>
>> >informat old_name $20.;
>>
>> >infile cards;
>>
>> >input old_name $;
>>
>> >label old_name= 'old_name';
>>
>> >cards;
>>
>> >name1
>>
>> >name2
>>
>> >name3
>>
>> >;
>>
>> >proc sql;
>>
>> >create table newtest as
>>
>> >select old_name as new_name
>>
>> >from test;
>>
>> >quit;
>>
>> >run;
>>
>> >In this case the variable "newname" in newtest has the label "old_name".
>>
>> It might be something to watch out for, especially since ODS does assign
>> labels to many of its variables automatically. At first in looking at the
>> data I was thinking that it was not changing the name for me, but upon
>> looking at the attributes, it was changing the name, but when I looked at
>> the data set I was looking at the old label! Thus the "as" keyword in Proc
>> SQL is behaving more like a rename than a computed new variable.
>>
>>
>>
>> >-Mary
>
|