BookmarkSubscribeRSS Feed
thanikondharish
Fluorite | Level 6

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 3411 views
  • 0 likes
  • 4 in conversation