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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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