BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AlG
Quartz | Level 8 AlG
Quartz | Level 8

Dear all,

I am in the process of matching two dataset which include a series of firms. The name of the same firm differs across the two datasets. For example, the equivalent of  "Bombay Sapphire Gin" from the first dataset is "Bombay Sapphire" in the second dataset. So I want to create a column in the first dataset which would include the name of the same firm in the second dataset. Below is my (partial) code. when I run this though, the new column includes only the first 10 characters of what I want. This means that whereas it returns "Aeromexico" correctly, instead of returning "Bombay Sapphire", it returns "Bombay Sap". The same thing happens to all of the names that are more than 10 characters. Can you please help me with this? Thanks in advance!

Data Test6;
    set work.Test5;
    If name= "Aeromexico" then MergeName= "Aeromexico";
    Else if name= "Bombay Sapphire Gin" then MergeName= "Bombay Sapphire";
Run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15
Data Test6;
    set work.Test5;
LENGTH MergeName $ 30;
    If name= "Aeromexico" then MergeName= "Aeromexico";
    Else if name= "Bombay Sapphire Gin" then MergeName= "Bombay Sapphire";
Run;

Here is the documentation link:

https://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=p1hgqgmxm3dpqcn1d4w5za5qbz0d.htm&doc...

 

Bart 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

2 REPLIES 2
yabwon
Onyx | Level 15
Data Test6;
    set work.Test5;
LENGTH MergeName $ 30;
    If name= "Aeromexico" then MergeName= "Aeromexico";
    Else if name= "Bombay Sapphire Gin" then MergeName= "Bombay Sapphire";
Run;

Here is the documentation link:

https://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=p1hgqgmxm3dpqcn1d4w5za5qbz0d.htm&doc...

 

Bart 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



sas-innovate-white.png

🚨 Early Bird Rate Extended!

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

 

Lock in the best rate now before the price increases on April 1.

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
  • 2 replies
  • 584 views
  • 4 likes
  • 3 in conversation