How do you group by a day from a date so you can display a group by a particular date? Surprisingly this is hard to Google.
You can use the datepart() function to extract date from a datetime stamp and then us proc freq of date (or get the counts from proc means/summary or proc sql) to get the number of entries per day.
Art, CEO, AnalystFinder.com
Can you provide an example of what you are trying to achieve?
Art, CEO, AnalystFinder.com
Generally when I here "group" and "date" then I think of formats. Can you provide an example of the dates you have and the "group" you need?
Are you attempting to assign a group, create a new variable, or just use the group in an procedure?
I’m looking a log table with one entry per time a user accesses an application, with a date time stamp. I am trying to view the number of times a user accesses the application per day.
You can use the datepart() function to extract date from a datetime stamp and then us proc freq of date (or get the counts from proc means/summary or proc sql) to get the number of entries per day.
Art, CEO, AnalystFinder.com
Art297 thank you, I was able to use date part.
put(datepart(wrs_date), yymmdd10.)
You shouldn't do the PUT() part, IMO. That converts it to a character field. Although it will sort correctly because you've used YYMMDD, it's easier to just use a SAS date .
datepart(wrs_date) format=yymmdd10. as ...
As indicated, apply the correct format, DTDATE9. can be used without creating a new variable. Note that PROC SQL does not respect formats so this type of summary cannot be done in SQL without creating the new variable.
proc freq data=sample noprint;
format datetime_var dtdate9.;
table date*user/out=summary;
run;
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.