BookmarkSubscribeRSS Feed
knargis160
Calcite | Level 5

Hi,

I am trying to calculate number of comments made per post-I have post-id and data set which only contains comments.

proc means noprint data=comments; by studyid post_id ; var studyid;class week group;
output out=nc_perpost min=xxx; run;

Can anyone help explaining more about "proc means noprint" and how should I verify my code.

Thanks,

 

7 REPLIES 7
Kurt_Bremser
Super User
  1. FORMAT your code. This spaghetti heap is not conducive to debugging and maintaining:
    proc means data=comments noprint;
    by studyid post_id;
    class week group;
    var studyid;
    output out=nc_perpost min=xxx;
    run;
  2. To verify the code, look at the resulting dataset (nc_perpost), and see if it meets your expectations.
  3. The NOPRINT option prevents creation of output via ODS.
knargis160
Calcite | Level 5

Can you also add the code to get mean/std sum for number of participants per post in the same code

ed_sas_member
Meteorite | Level 14
proc means data=comments noprint n mean sum std;
	by studyid post_id;
	class week group;
	var studyid;
	output out=nc_perpost n= mean= std= sum= / autoname;
run;
ed_sas_member
Meteorite | Level 14

Hi @knargis160 

 

I am not sure that PROC MEANS is the better way to do this job.

PROC FREQ or Proc SQL for example could be a better approach to compute frequencies.

Could you please share a sample of data and the desired output?

knargis160
Calcite | Level 5

Can you give a example code in proc sql or proc freq about how to calculate total number of (any variable) per any variable?

Reeza
Super User

https://www.listendata.com/2015/01/sas-detailed-explanation-of-proc-means.html

 

FREQ won't calculate STD. SQL can but it's not as efficient as PROC MEANS.

 

 

Astounding
PROC Star

My spider sense is tingling.  It seems you might need a lot of help on this.

 

If you want to compute statistics (mean, std, sum) on a numeric variable. that variable has to exist in your data set.  I'm not sure from your post that it actually exists.  Perhaps your data set has a single observation per post, and you have to count those first.

 

Does your data set really contain variables named WEEK and GROUP?  If so, what do they represent and how do they affect what you want to count?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 959 views
  • 1 like
  • 5 in conversation