Learning SAS? Welcome to the exclusive online community for all SAS learners.

How get last week count of current time and current time of today count

Reply
Occasional Contributor
Posts: 13

How get last week count of current time and current time of today count

Hi,

I request you to please give the code for how get last week count of current time, And current time of today count.

 

Data

IdDateTimeProduction Production Count
17/14/20171:45:00 PM1
27/15/20171:45:00 PM1
37/16/20171:45:00 PM1
47/4/20171:45:00 PM1
57/5/20171:45:00 PM1
67/6/20171:45:00 PM1
77/7/20171:00:00 PM1
87/8/20171:00:00 PM1
97/9/20171:00:00 PM1
107/10/20171:00:00 PM1
117/11/20172:00:00 PM1
127/12/20172:00:00 PM1
137/13/20172:00:00 PM1
147/14/20172:00:00 PM1
157/15/20172:00:00 PM1
167/16/20172:00:00 PM1
127/17/20171:00:00 PM1
137/17/20171:00:00 PM1
147/17/20172:00:00 PM1
157/17/20172:00:00 PM1
167/17/20172:00:00 PM1

 

Expected Answer: last week count (@2:00:00 PM)=6, and today count (@2:00:00)=3

Super User
Posts: 6,946

Re: How get last week count of current time and current time of today count

Do a count for time = 02:00 PM and date = today(), and another count for time = 02:00 PM and today() -7 <= date <= today() - 1.

How you formulate the comparisons depends on the structure of your dataset (variable types).

Please post your example dataset in a data step for easy recreation. Use the macro provided in https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... for the conversion.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 1 reply
  • 126 views
  • 2 likes
  • 2 in conversation