shandayani
asked on
How do i group date variables in SAS Output?
I am working with a table that holds data on patient visits. There is a "Visit Date" column and the dates contained in it span over 6 years (Thousands of records).
I want to run a frequency distribution on the entire table but this gives me countless lines of output due to the variability of the dates.
What I am trying to do is to use PROC FORMAT to group the date output into 3 months each so that i can better read my data. Please is there a way this can be done?
I want to run a frequency distribution on the entire table but this gives me countless lines of output due to the variability of the dates.
What I am trying to do is to use PROC FORMAT to group the date output into 3 months each so that i can better read my data. Please is there a way this can be done?
ASKER
Thanks for you reply.
I did forget to mention that I am using SAS though. Will this still work?
I have never used SELECT statements with in SAS.
I did forget to mention that I am using SAS though. Will this still work?
I have never used SELECT statements with in SAS.
It should. give a try.
What is needed is
PROC SQL;
SELECT YEAY(VisitDate) AS Year_VisitDate,
... As above ...
... End with a semicolon ...
;
QUIT;
check out the documentation for. PROC. SQL. it's syntax is very different to other PROCS. However it is very useful.
Ian
PROC SQL;
SELECT YEAY(VisitDate) AS Year_VisitDate,
... As above ...
... End with a semicolon ...
;
QUIT;
check out the documentation for. PROC. SQL. it's syntax is very different to other PROCS. However it is very useful.
Ian
Or you can just SASstandard formats,
PROC FREQ data=your_data order=formatted;
FORMAT VisitDate. YYQC6.0;
TABLES VisitDate;
RUN;
_____________
This ,applies a format of yyyy:q To the date variable and the order=formatted. Makes it use this formatted value for the summary, instead of the full formatted date.
Ian
PROC FREQ data=your_data order=formatted;
FORMAT VisitDate. YYQC6.0;
TABLES VisitDate;
RUN;
_____________
This ,applies a format of yyyy:q To the date variable and the order=formatted. Makes it use this formatted value for the summary, instead of the full formatted date.
Ian
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window