BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jedrzej
Obsidian | Level 7

Hi,

 

I have two data sets.

 

First data set contains two variables ID and Description

 

Second data set has variables with observations that contains numbers. These numbers are corelated with ID numbers from the first data set.

 

Now my task is to change this numbers from the second data sets to the description from the first set . I've tried with joins but this is not efficient and takes a lot of time. Any ideas ?

 

first data set

 

ID   Description

14   yellow

 

second data set

 

Color

 14

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

e.g.:

data descriptions;
  input ID   Description $50.;
  cards;
14   yellow
;

data have;
  input Color;
  cards;
14
;

data for4mat;
  set descriptions (rename=(id=start description=label)) end = last;
  retain fmtname 'ccode' type 'N';
run;


proc format cntlin = for4mat;
run;

data want;
  set have;
  length Color_Description $50.;
  Color_Description=put(color,ccode.);
run;

Art, CEO, AnalystFinder.com

View solution in original post

2 REPLIES 2
art297
Opal | Level 21

I'd create and apply a format.

 

Art, CEO, AnalystFinder.com

art297
Opal | Level 21

e.g.:

data descriptions;
  input ID   Description $50.;
  cards;
14   yellow
;

data have;
  input Color;
  cards;
14
;

data for4mat;
  set descriptions (rename=(id=start description=label)) end = last;
  retain fmtname 'ccode' type 'N';
run;


proc format cntlin = for4mat;
run;

data want;
  set have;
  length Color_Description $50.;
  Color_Description=put(color,ccode.);
run;

Art, CEO, AnalystFinder.com

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
  • 2 replies
  • 504 views
  • 2 likes
  • 2 in conversation