Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 657
  • Last Modified:

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?
0
shandayani
Asked:
shandayani
  • 3
  • 2
1 Solution
 
SharathData EngineerCommented:
try grouping on Year and Quarter.
SELECT YEAR(VisitDate) AS Year_VisitDate, 
         QTR(VisitDate)  AS Qtr_VisitDate, 
         COUNT(* ) 
    FROM your_table 
GROUP BY YEAR(VisitDate), 
         QTR(VisitDate)

Open in new window

0
 
shandayaniAuthor Commented:
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.
0
 
SharathData EngineerCommented:
It should. give a try.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ShannonEECommented:
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
0
 
ShannonEECommented:
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
0
 
ShannonEECommented:
Or you can just SASstandard formats,

PROC FREQ data=your_data order=formatted;

      FORMAT VisitDate  YYQC6.0;

      TABLES  VisitDate;

RUN;

((no full stop after format variable name ))

Ian
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now