Hi All,
I am trying to concatenate some character variables and one of those variable is SYS date and time. SYS date and time should be YYYY-MM-DD:hh:mm:ss format. Can someone help me please. Thanks.
The code i am trying to write is like:
DATA test;
Long_char='1234'||'ABCD'||System date and Time;
RUN;
Expected output:
Long_char=1234ABCD2016-02-09:15:41:29
You can use datetime() function instead. My personal preference is to use the CATT function, I find it more readable.
%put %sysfunc(datetime(), datetime21.);
data want;
long_var = catt("1234", "ABCD", put(datetime(), datetime21.));
run;
proc print data=want;
run;
Hi LinusH,
Thank for your code, but I don't know how to put it in the data step. Would you please put your code in the following data step so that I can get my expected result. I never worked with a let statement. Thanks.
DATA have;
long_char='1234'||'ABCD'||SYS date and SYS time;
RUN;
Expected output:
long_char=1234ABCD2016-02-09:15:41:29
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!
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.