BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

 

In my pgm, when i created variables d,e f, in data step two,  I am seeing the variable labels for these variables. i need to carry labels of source variables. Please suggest

data one;
input a $ b $ c;
label a ='some' b='somm' c='somn';
datalines;
nn ss 1
dk mm 2
;

data two;
set one;
d=a;
e=b;
f=c;
run;

 

 

3 REPLIES 3
ballardw
Super User

Create a data set with the names of the variables and labels from the starting set.

Add the matching new variable names to that data set.

Use the data set to write Proc Datasets code to modify data set 2 after creation to use the labels.

You can find some examples on the forum of using Call Execute in a data step to call Proc datasets to rename variables, label syntax would be similar using the New name and old label in a modify block.

 

 

 

 

FreelanceReinh
Jade | Level 19

Hi @knveraraju91,

 

Another option:

proc sql;
create table two as
select *, a as d, b as e, c as f
from one;
quit;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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