Search code examples
sqlsas

SAS: In proc sql, how does one preserve the variable label when performing operations on that variable?


In SAS proc sql, how do I preserve the label of myvar (in myoldtable) when performing the following simple operation?:

proc sql; create table mytable as select myvar*1.5 as myvar from myoldtable; quit;


Solution

  • Would it be possible to just update myoldtable instead? That will do the math and preserve your variable name...

    proc sql;
        update myoldtable
        set myvar=myvar*1.5;
    quit;
    

    Of course, if you're really stuck on getting the new table, you could always do this:

    proc sql;
        create table mynewtable as
        select * from myoldtable;
    
        update myoldtable
        set myvar=myvar*1.5;
    quit;