I am working on a data similar to this
And the data I want should be like as below:
I want to count number of emails approved on the date.
Can someone guide how should I approach this problem.
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;
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.
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;
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.
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.
I was working on SAS, I have data something like this.
Now what I want is Frequency of each email_id approval against EMP_CODE.
EMP_CODE | DOA ON 7 | DOA on 8 | DOA on 9 |
1001 | 3 | 0 | 1 |
1002 | 0 | 2 | 0 |
1003 | 0 | 1 | 1 |
1004 | 1 | 1 | 0 |
1005 | 0 | 1 | 2 |
1006 | 1 | 0 | 0 |
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.
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.
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.
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.