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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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