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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 3 replies
  • 2652 views
  • 0 likes
  • 4 in conversation