BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Cynthia_sas
SAS Super FREQ

Hi:

As another example of a lookup technique, my tendency would be to make a user-defined format from the file with the name1-name3 and then to use that format when reading data file A to make the NEWNAME variable.

 

Something like this:


data fmt_examp(keep=fmtname start end label);
  length start $50 end $50 label $50 ;
  retain fmtname '$namef' type 'C';
length name1 name2 name3 $50;
infile datalines dlm=',' dsd;
input name1 $ name2 $ name3 $;
label=name1;
start=name1; end=name1;
output;
start=name2; end=name2;
output;
start=name3; end=name3;
output;
datalines;
"International Business Machines","IBM","IBM Corp."
"Apple","Apple Inc.","AAPL"
"Google LLC","GOOGL","Google"      
;
run;

proc format cntlin=fmt_examp fmtlib;
run;

data a;
length name newname $50;
input id $ name $;
newname = put(name,$namef.);
cards;
01        IBM
02        Apple
;
run;

proc print data=a;
title 'Using format for lookup';
run;
 
 

 

(There's always more than 1 way to do things in SAS.)

 

Cynthia

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 15 replies
  • 1361 views
  • 2 likes
  • 5 in conversation