I'm trying to get a total count as well as a break count by login_user_id. From what I found on the web, the following code should work, but it does not give me a total count. Could someone please advise me on what I'm missing?
proc print data=R_WData.Mapext4 label sumlabel n='Login Count = ' 'Total Login Count = ';
by login_user_id;
id login_user_id;
var Fname Lname login_user_id Activity_attempt_dttm;
title1 "Users for a Selected Time Period";
run;
You are missing a sum statement, but I don't think that will help you with this dataset, as you don't have anything to sum.
If you had a numeric variable for which a sum would be relevant, e.g., time_spent, then you could use something like:
proc print data=R_WData.Mapext4 label sumlabel n='Login Count = ' 'Total Login Count = ';
by login_user_id;
id login_user_id;
var Fname Lname login_user_id Activity_attempt_dttm;
sum time_spent;
title1 "Users for a Selected Time Period";
run;
and you would then obtain what you are looking for.
I think you need to use proc report or tabulate instead of proc print for this.
: If the OP doesn't have any variable to sum, I agree with you that tabulate or report may be needed.
However, I find it interesting that including a sum statement, with no variables, doesn't product any error, but doesn't honor the 2nd title for the n= option.
Since every time I've submitted anything to the SAS ballot, I've gotten an unsatisfactory response, I won't submit one in this case. However, I'd call this a bug (actually two discrepancies in the manual). One or more variables are supposedly required with a sum statement, but apparently aren't. And, when a sum statement is included, proc print is supposed to do the total sum and honor the secondary n= variable label line.
Is anyone from SAS reading this?
I think that the issue is using the combination of BY and ID variables. This has always been a special case for PROC PRINT. Doing that will defeat the SUMLABEL option.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.