Hello everyone,
I want to concatenate two character variables in SAS and wishing to include Parenthesis with second variable. I am able to do that with the help of traditional || method but I was wondering if would do that with CAT series functions. I have converted numeric variable to character/string.
Data A;
input;
Date $10. Devdate$ XY$;
datalines;
19JAN1990 23 U/L
23Mar1987 46 U/L
;
run;
I am wishing to see final result with anew variable named ABC and the value should be concatenation of Date and Devdate with parenthesis. Final result should be 19Jan1990(23) but with Cat series functions. Thanks!
data want;
length ABC $20;
set a;
ABC=CAT(strip(date),'(',strip(Devdate),')');
run;
Remove leading and trailing blanks before concatenation. CAT() function default length is 200, you can set the length if you don't want the default.
@shanky_44your want is 19Jan190(23) should it be 19Jan1990(23) if so then
Put the ( into quotes like this:
Data A;
input
Date $10. Devdate$ XY$;
datalines;
19JAN1990 23 U/L
23Mar1987 46 U/L
;
run;
data A;
set A;
abc = compress(date||"("||Devdate||")");
run;
If you really want 19Jan190(23) you will need to remove ether the first or second 9 in the incoming date.
@VDD wrote:
@shanky_44your want is 19Jan190(23) should it be 19Jan1990(23) if so then
I don't understand this part-19Jan190(23) either
Thanks VDD!
data want;
length ABC $20;
set a;
ABC=CAT(strip(date),'(',strip(Devdate),')');
run;
Remove leading and trailing blanks before concatenation. CAT() function default length is 200, you can set the length if you don't want the default.
Sorry, that was a type error. I am wishing to get final result like 19Jan1990(23) which is concatenation of two variables. Thanks for your reply. It is working. Thanks once again!
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!
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.