Hi, I want to use proc freq in order to create a table that shows me submissions created during a specific time period.
The dates I have are listed as dd-mm-yyyy and I'm looking to calculate the year for the table to tell me how many submissions I have for the year, for example the time period runs from 2018-2021 so I want the table to tell me how many submissions I have for 2018, 2019, 2021 individually instead of it showing me every single submission on its own.
Any idea on how to calculate the year?
it is a character variable, in my table the dates show up as DDMMYYYY, for example, my received_date for the submissions show up as 10APR2018 18APR2018 24APR2018 and instead of each one showing up individually, I want to calculate the year for it just tell me that in 2018 I had __ number of submissions
Advice: always use numeric SAS date values, not character strings. There are so many SAS functions and formats and other features that work properly with numeric SAS date values, that will make your life easier, there's really no reason to not use them.
Example:
data intermediate;
set have;
date_numeric=input(date,date9.); /* Convert character date to numeric date */
run;
proc freq data=intermediate;
tables date_numeric/out=want;
format date_numeric year4.;
run;
that worked, thank you!
Did you run PROC CONTENTS or inspect the variable attributes by right-clicking on it in the table viewer?
You say it is formatted as DDMMYYYY, but then you show dates in the SAS-typical DDMMMYYYY format.
Please confirm the type and display format of the variable before we proceed.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: