🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- « Previous
-
- 1
- 2
- Next »