BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5

data s ;
name='joseph' ;
new='peter ';
run;

how to assign value of name variable as a label of new variable  like see below

 

joseph

he is a stat programmer

 

harish

harish

3 REPLIES 3
gamotte
Rhodochrosite | Level 12

I don't understand your example.

Is this what you want ?

 

data _NULL_;
set s;

call execute(cats('data S; set S; label new="',name,'"; run;'));
run;
andreas_lds
Jade | Level 19

Sorry, but i don't understand what you try to do.

What happened to Peter?


@thanikondharish wrote:

data s ;
name='joseph' ;
new='peter ';
run;

how to assign value of name variable as a label of new variable  like see below

 

joseph

he is a stat programmer

 

harish

harish


 

ballardw
Super User

@thanikondharish wrote:

data s ;
name='joseph' ;
new='peter ';
run;

how to assign value of name variable as a label of new variable  like see below

 

joseph

he is a stat programmer

 

harish

harish


LABEL is a variable property. You can only have one label for a given variable. And does it need to be a label of a variable or the column heading for a report?

Give a more complex example of what you are attempting such as with three records with different values of name and "new" and what the resulting data set should look like.

 

Proc Transpose can use the value of variable to NAME a variable using the ID statement.

sas-innovate-white.png

Missed SAS Innovate in Orlando?

Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 3298 views
  • 0 likes
  • 4 in conversation