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

Hi all,

 

I am looking to proc import an excel file with 4 columns. Then, I would like to merge all 4 columns together IN SAS. Problem is all 4 columns have a different amount of observations. So, when I proc print this, how do I merge the columns without getting any blank observations?

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try

 

length merged $64;

merged = catx(",", of col1-col4);

 

The catx function concatenates its arguments, separated by the first argument. It ignores missing values.

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Try

 

length merged $64;

merged = catx(",", of col1-col4);

 

The catx function concatenates its arguments, separated by the first argument. It ignores missing values.

PG
ballardw
Super User

@PGStats wrote:

Try

 

length merged $64;

merged = catx(",", of col1-col4);

 

The catx function concatenates its arguments, separated by the first argument. It ignores missing values.


By default a Missing value for a numeric will appear as . in the result.

 

data example;
    col1='abc';
    col2=.;
    col3=3;
    col4='pdq';
    merged= catx(',',of col1-col4);
run;

/* will yield Merged = "abc,.,3,pdq" */

If you set the missing character to blank then the concatenated version will be missing

options missing=' ';
data example;
    col1='abc';
    col2=.;
    col3=3;
    col4='pdq';
    merged= catx(',',of col1-col4);
run;

/* merged = "abc,3,pdq" */

So if you have numeric values you may have one or more issues to resolve in determining the exact result desired.

 

Since this post started with importing Excel it is hard to determine what type of values you may have.

 

sas-innovate-wordmark-2025-midnight.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. Sign up by March 14 for just $795.


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
  • 698 views
  • 0 likes
  • 3 in conversation