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

Hello

I want to combine 10 char columns and add a comma separator.

The problem that some columns has null  value and then in the resulted field there are 

For example:

The resulted value in first row is looking like that::

118-106-201-.-.-.-.-.-.-.

I would like to see it as  118-106-201

What is the way to do it please?

 

The code statement that I run is 

Reason_Reject=CATX('-',OF _temp1-_temp10);

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

These cannot be missing character variables, as this works perfectly:

data test;
infile datalines dlm="," dsd truncover;
input (_temp1-_temp10) (:$3.);
Reason_Reject = CATX('-',OF _temp1-_temp10);
datalines;
118,106,201
;

Maxim 3: Know Your Data. Types, formats, content.

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

These cannot be missing character variables, as this works perfectly:

data test;
infile datalines dlm="," dsd truncover;
input (_temp1-_temp10) (:$3.);
Reason_Reject = CATX('-',OF _temp1-_temp10);
datalines;
118,106,201
;

Maxim 3: Know Your Data. Types, formats, content.

PeterClemmensen
Tourmaline | Level 20

Does _temp4 contain a "." or an actual missing value " " ?

Ronein
Onyx | Level 15
I found the reason, the fields were numeric and then SAS automatically convert them to char during the concatenation process and then value with null value were converted to '.'
Ksharp
Super User
Add the following option at top of your code.

options missing=' ';

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1013 views
  • 3 likes
  • 4 in conversation