BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kuridisanjeev
Quartz | Level 8

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.

art297
Opal | Level 21

: limit what is output from proc compare.  e.g.:

Proc contents data=t

out=lab(keep=name label where=(not missing(label)));;

run;

kuridisanjeev
Quartz | Level 8

Thanks a lot  !!!!...Sounds pretty Simple....

Not Sure how  i missed this...

Sanjeev.k

dishant
Calcite | Level 5

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 18 replies
  • 1840 views
  • 6 likes
  • 8 in conversation