BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Kirito1
Quartz | Level 8

I am working on a data similar to this

Kirito1_0-1673341554777.png

And the data I want should be like as below:

Kirito1_1-1673341602606.png

I want to count number of emails approved on the date.

Can someone guide how should I approach this problem.

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

If you're after code then it's normally really appreciated if you provide sample data in the form of a working SAS data step (similar to the Have data step below), show the desired result and explain the logic to get from have to want.

data have;
  infile datalines dsd truncover;
  input emp_id $ doa :date9.;
  format doa date9.;
  datalines;
1001,01jan2023
1001,01jan2023
1001,02jan2023
1002,01jan2023
1002,02jan2023
1002,04jan2023
;

options missing=' ';
proc tabulate data=have;
  class emp_id doa;
  keylabel n=' ';
  table emp_id, doa;
run;

Patrick_0-1673345656592.png

You could also use Proc Means or Proc Report for such a report. Each procedure provides a bit different functionality with Proc Report providing the most flexibility when it comes to layout and additional "in report" calculations.

 

You didn't write it explicitly but I made the assumption you're after a report and not a table - also because the data structure of your Have table is "better" to work with than it would be for a Want table with the structure you're showing.

View solution in original post

6 REPLIES 6
Kirito1
Quartz | Level 8
I mean if some could write a pseudo code with what functions and procedures to use. It would be a great help.
Patrick
Opal | Level 21

If you're after code then it's normally really appreciated if you provide sample data in the form of a working SAS data step (similar to the Have data step below), show the desired result and explain the logic to get from have to want.

data have;
  infile datalines dsd truncover;
  input emp_id $ doa :date9.;
  format doa date9.;
  datalines;
1001,01jan2023
1001,01jan2023
1001,02jan2023
1002,01jan2023
1002,02jan2023
1002,04jan2023
;

options missing=' ';
proc tabulate data=have;
  class emp_id doa;
  keylabel n=' ';
  table emp_id, doa;
run;

Patrick_0-1673345656592.png

You could also use Proc Means or Proc Report for such a report. Each procedure provides a bit different functionality with Proc Report providing the most flexibility when it comes to layout and additional "in report" calculations.

 

You didn't write it explicitly but I made the assumption you're after a report and not a table - also because the data structure of your Have table is "better" to work with than it would be for a Want table with the structure you're showing.

Kirito1
Quartz | Level 8
Thank you so very much..............Patrick.......Much Appreciated man
PaigeMiller
Diamond | Level 26
proc freq data=have;
    tables emp_code1*date_of_approval;
run;

Please, from now on, do not provide data as screen captures, do not provide data as Excel files. Please provide data as working SAS data step code, which you can type yourself, or follow these instructions.

--
Paige Miller
Kirito1
Quartz | Level 8

I was working on SAS, I have data something like this.

Kirito1_0-1673336706297.png

Now what I want is Frequency of each email_id approval against EMP_CODE.

EMP_CODEDOA ON 7DOA on 8DOA on 9
1001301
1002020
1003011
1004110
1005012
1006100

One way is to extract 3 data for each date and use proc freq and then joining all those three proc freq to join(I dont know if thats even possible).

help would be appreciated greatly.........Thank you in advance for all the contributors.

PaigeMiller
Diamond | Level 26

Please provide example data as working SAS data step code, which you can type in yourself, or you can follow these instructions. We cannot work with data in screen captures or data in Excel files.

 

Please do not double-post your question. The answer using PROC FREQ is in your other thread.

--
Paige Miller

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Early bird rate extended! Save $200 when you sign up by March 31.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 846 views
  • 2 likes
  • 3 in conversation