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
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.