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