table lookup

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

table lookup

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


Accepted Solutions
Solution
‎06-01-2017 09:43 AM
PROC Star
Posts: 7,437

Re: table lookup

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


All Replies
PROC Star
Posts: 7,437

Re: table lookup

I'd create and apply a format.

 

Art, CEO, AnalystFinder.com

Solution
‎06-01-2017 09:43 AM
PROC Star
Posts: 7,437

Re: table lookup

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 127 views
  • 2 likes
  • 2 in conversation