Hi, I need to concat Date and Time using proc sql
So I did that: 🙂
cat(put(day(Date),z2.),'/',put(month(Date),z2.),'/',year(Date),' ',put(hour(Time),z2.),':',put(minute(Time),z2.),":",put(second(Time),z2.)) as DateTime
Anyone can show me another way please one that I don’t mess with the column format
Ok it works, but i need this format 15/05/18:08:27:30 and datetime. returns 15MAY18:08:27:30.
The value appears correct, what you are actually saying is that the display format does not meet you expectation/ need.
SAS provides a very large number of date, time and datetime display formats but cannot meet every single need. However you can create custom display format using Proc format with the Picture statement and directives. Warning for the code below: The quotes around the funny list of %0d/%0m/0%y:%0H:%0M:%0S must be single quotes or else SAS will think you are using macro variables. The case on the d m y H M and S are significant. Changing from 'm' to 'M' for instance will change the displayed value from month number to Minutes (and vice versa). The 0 are to display leading zeroes for values less than 10. Since this is not SAS supplied format it will be up to you to make sure the format is available when ever you need to use it. Either rerun the code every session or add the format to permanent format catalog.
proc format library=work; picture mydttime low - high= '%0d/%0m/0%y:%0H:%0M:%0S' (datatype=datetime) ; run; data junk; x='15MAY18:08:27:30'dt; put x= mydttime.; run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.