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

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
Meteorite | Level 14
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=' ';

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 604 views
  • 3 likes
  • 4 in conversation