DATA Step, Macro, Functions and more

Max n Min of Dates

Reply
Contributor
Posts: 66

Max n Min of Dates

Hi,

 

I am looking to create a report which has the Maximum/Minimum of Unique-ids a Patient visited had on any day within 2015-16.

 

My table looks like this.

Datatypes:--- ID Char

                      Year Number,

                      Month Number,

                      Day Number,

                      product Char,

                     First visit date Timestamp

 

Product Year Month Day Count(ID) as ID

216ABCE 2015 7     3        1

ASSDE    2015         9       1

uJKILEY   2016      29    7

216ABCE 2015 9     13       3

ASSDE    2015  9      9      1 1

uJKILEY   2016  9    20   709

Please suggest.

 

 

 

Super User
Posts: 5,498

Re: Max n Min of Dates

Posted in reply to santosh_pat69

Suggestions to get started.

 

First, combine the month, day, and year:

 

sasdate = mdy(month, day, year);

 

That will make the coding easier to read.

 

Second, add PATIENT to your data set.  It's really not possible to perform calculations based on PATIENT when it is not even part of your data.

 

Third, why would you replace ID with COUNT(ID)?  Wouldn't that make the report confusing?

Contributor
Posts: 66

Re: Max n Min of Dates

Posted in reply to Astounding

Hi,

 

Thank you for your quick reply,

I have used the count(ID) as i need to get the max and min of the number of times a patient has visited the hospital.

The data type of ID is char,

Kindly suggest.

 

We are looking for the minimum  & Maximum number of times a patient has visited based on the Patient ID.

 

 

 

Super User
Posts: 5,498

Re: Max n Min of Dates

Posted in reply to santosh_pat69

As you probably guessed, since ID is character you would not store a count in ID.  If you plan on programming using SQL, you could use something like:

 

count(ID) as n_hospital_visits

 

I don't see hospital in the data either, though.  You may need to update your description of the data.

Ask a Question
Discussion stats
  • 3 replies
  • 251 views
  • 1 like
  • 2 in conversation