BookmarkSubscribeRSS Feed
Tushar
Obsidian | Level 7

Hi All,

i have a dataset name custtrasac which given below and contain customer transaction details day wise. Now the problem is i have not used proc report for indepth calculation and i have asked to create report which contain 1)monthwise transaction details order by customer id 2) Also i want commulative frequency for transaction id for every month? Can anyone please help me for this code using Proc report only?

custid   transactionId   dates

=====================

1001     100001          1/1/2012

1002     100002           1/2/2012

.

.

.

.

.

.

.

.

.

1100     100100     12/31/2012

Thanks,

Tushar J

2 REPLIES 2
Cynthia_sas
SAS Super FREQ


Hi:

  PROC FREQ is much better at giving you cumulative frequency than PROC REPORT. What is the reason you must use PROC REPORT? But you want 2 reports, as numbered above, right? You show very little data - there's not enough to run a test. And, you don't show what the output should look like. What is the type of report you need? HTML, RTF, PDF?

  For report #1 (the customerid report), what are "monthwise transaction details" -- you only show 3 variables, but there are no amounts to summarize, so the only calculated numbers you could get would be N and PCTN and whatever you calculate. For report #2 (the transaction report), you say that you want cumulative frequency for tranactionid for every month -- so this report would be basically a count of customerids for every month? The way you show your data, it looks like every transaction id sort of "matches" every customer id -- the way you show it, every transaction id is unique on every row and every customer id is unique on every row. Could you have duplicate transaction ids? Could you have duplicate customer ids? Is there any linkage between customer id and tranaction id?

Could 1 customer have multiple transactions?

custid   transactionId   dates

==================================

1001     100001          1/1/2012

1002     100012          1/2/2012

1002     100022          1/2/2012

1002     100032          1/3/2012

1003     100013          1/1/2012

1003     100023          1/1/2012

OR,

could multiple customers have the same transactions on the same day or different days?

custid   transactionId   dates

==================================

1001     100001          1/1/2012

1002     100001          1/2/2012

1002     100002          1/2/2012

1002     100003          1/3/2012

1003     100002          1/1/2012

1003     100003          1/2/2012

   

  What code have you tried? Knowing these details and the destination you want and the code you've tried will help anyone who might have some ideas of how to help you with this question. Here's some sample code using "fake" data that contains duplicate customer id values and duplicate transaction values and duplicate days, along with an example of what you might get from PROC FREQ by default.

cynthia

ods _all_ close;
     
data stuff;
  infile datalines dlm=',';
  input custid transactionid dates : mmddyy10.;
return;
datalines;
1001,1000942,01/01/2012
1001,1000157,01/01/2012
1037,1000314,01/01/2012
1037,1000000,01/01/2012
1037,1000414,01/01/2012
1145,1000314,01/01/2012
1149,1000157,01/01/2012
1181,1000628,01/02/2012
1181,1000471,01/02/2012
1217,1000942,01/02/2012
1217,1000628,01/02/2012
1217,1000011,01/02/2012
1289,1000157,02/01/2012
1014,1000314,02/01/2012
1038,1000314,02/01/2012
1050,1000471,02/01/2012
1074,1000472,02/01/2012
1074,1000942,02/01/2012
1098,1000628,02/01/2012
1001,1000471,02/01/2012
1037,1000785,02/01/2012
1182,1000314,02/01/2012
1206,1000942,02/01/2012
2166,1000785,02/02/2012
2166,1000157,02/02/2012
2166,1000000,02/02/2012
2226,1000471,02/02/2012
2238,1000472,02/02/2012
2250,1000785,02/02/2012
2286,1000471,02/02/2012
2310,1000942,02/02/2012
2370,1000314,02/02/2012
1289,1000011,02/02/2012
1217,1000628,02/02/2012
;
run;
    
ods noptitle;
ods html file='c:\temp\cumfreq.html' style=sasweb;
proc freq data=stuff;
  title '1) Proc Freq Default';
  tables dates*transactionid
         dates*custid/ list nopercent;
  format dates monname3.;
run;
ods html close;

Tushar
Obsidian | Level 7

Hi Cynthia,

sorry for my late reply. Actually all i want to know is how proc report can done proc freq work, however i understood that the problem statement which i have mentioned is not clear. This is something i was being asked and i guess i need to check this back again. All i am trying to get familier with the Proc REPORT. but thanks a lot for this information. i will check the correct problem statement and will get back in discussion incase i am not able to solve. Thanks Again Cynthia for your reply.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 751 views
  • 3 likes
  • 2 in conversation