Hi,
Interesting Question...initially i thought it was very easy to assign labels from one variable to another,but when i put my fingers on the key board,my brain stopped working.:smileysilly:
any how I tried bellow code.i know this was lengthy and not so effective method also,but the good thing is it is working well.But I am getting
"Variable is uninitialized" note in the log.
Is there any way avoid this note,i mean could any one make some amendments to bellow code to prevent the Log note(Variable is uninitialized) ?
Data t;
input A A1 b c ;
label A ="Test";
label C ="Test1";
A_char=put(A,1.);
C_char=put(C,1.);
cards;
2 5 5 9
4 8 8 8
;
run;
Proc contents data=t out=lab(keep=name label where=(not missing(label)));
run;
Proc Sql;
Select compress(Name||"_char"||"="||' " '||label||' " ') into : labs separated by ' ' from lab;
quit;
Data new;
set T;
label &labs;
run;
Thanks for your time..
Reagrds,
Sanjeev.K
Message was edited by: Sanjeev Kuridi Code working perfect now. I have updated the code as Art suggested.
Hi,
You can use vlabel to get the label in one step and then a proc datasets to assign the label.The Following Is My code.
data chk;
input var_C $;
label var_c="First Variable";
datalines;
1
2
3
4
56
;
Run;
data chk1(drop=var1_cC);
set chk (rename=(var_c=var1_CC));
var_N=input(var1_CC,6.);
call symput ("var1_label",vlabel(var1_cC));
Run;
%put &var1_label;
proc datasets lib =work nolist nodetails;
modify chk1;
label var_N="&var1_label";
run; quit;
If Any concern Pls Let Me know.
Regards,
Dishant Parikh
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.