New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
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

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

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
  • 2376 views
  • 2 likes
  • 5 in conversation