I have a data set that has been compiled and I have to concatenate 3 of the fields.
1 field is a character field : CUST-123
2nd Field is numeric: 56789
3rd field is a date field: 01/Sep/2020
proc sql;
select CUSTID||''||put(NUMBER_ID,10.)||''||put(CREATION_DATE_TIME,10.) from TABLE;
run;
Using the Put it changes the 2 non character fields to character but my result set comes out as:
CUST-123 6523574 22159
I tried trim but that doesnt work. I want the result set but without any spaces
You can use CATT() instead which will trim all trailing spaces. Did you want the date as the SAS date value or a number such as 20200901?
proc sql;
select
catt(custid, put(number_id, z10.), put(creation_date_time, yymmddn10.)) as want from table;
quit;
run;
@Jyuen204 wrote:
I have a data set that has been compiled and I have to concatenate 3 of the fields.
1 field is a character field : CUST-123
2nd Field is numeric: 56789
3rd field is a date field: 01/Sep/2020
proc sql;
select CUSTID||''||put(NUMBER_ID,10.)||''||put(CREATION_DATE_TIME,10.) from TABLE;
run;
Using the Put it changes the 2 non character fields to character but my result set comes out as:
CUST-123 6523574 22159
I tried trim but that doesnt work. I want the result set but without any spaces
What does your desired result look like?
Where does 6523574 come from?
My end result that i want would be
CUST-123652357422159
6523574 is just an arbitrary number in my data
See if this works for you.
data _null_;
_1 = "CUST-123";
_2 = 56789;
_3 = '01sep2020'd;
want = cats(_1, _2, _3);
put want=;
run;
Would i just be using the field names ?
_1 = CUST_ID etc?
You can use CATT() instead which will trim all trailing spaces. Did you want the date as the SAS date value or a number such as 20200901?
proc sql;
select
catt(custid, put(number_id, z10.), put(creation_date_time, yymmddn10.)) as want from table;
quit;
run;
@Jyuen204 wrote:
I have a data set that has been compiled and I have to concatenate 3 of the fields.
1 field is a character field : CUST-123
2nd Field is numeric: 56789
3rd field is a date field: 01/Sep/2020
proc sql;
select CUSTID||''||put(NUMBER_ID,10.)||''||put(CREATION_DATE_TIME,10.) from TABLE;
run;
Using the Put it changes the 2 non character fields to character but my result set comes out as:
CUST-123 6523574 22159
I tried trim but that doesnt work. I want the result set but without any spaces
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.