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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 7 replies
  • 896 views
  • 1 like
  • 5 in conversation