Hi all
I have data called fat, and it has variable PR and TEST DATE as well as COW ID.
Each cow has four test dates or more, and PR variable has four different levels.
My question is I want to know the average number of test dates per cow for each PR level.
someone told me it could be by using proc freq for cow id * pr, but I couldn't figure out that code
I hope you got my query
Regards
Ibrahim
Example input data and example output for the given input really helps.
Here is an example of determining the average number of models of cars per make (or brand). You should have this data set to examine.
proc freq data=sashelp.cars noprint; tables make*type /out=makecount; run; proc means data=makecount mean; var count; run;
The first step counts how many times combinations of MAKE and TYPE appear in the data. In this case there is one record per MODEL.
Then average the resulting count. Which yields the average number of records for MAKE and type combinations.
I think that COWID would take the place of MAKE and TYPE would be your PR. Which would give the average number of records per cow and pr.
If you need something else, provide some small actual example data for input and the output you want for that input.
Please show an example of your data and the SAS code you have tried.
COW_ID CAL_TE CEA PR TEST_DATE
71988495 06/09/2011 1 4 10/01/2012
71988495 06/09/2011 1 4 02/02/2012
71988495 06/09/2011 1 4 06/03/2012
71988495 06/09/2011 1 4 05/04/2012
71988495 06/09/2011 1 3 05/05/2012
75170579 07/10/2013 1 3 15/01/2014
75170579 07/10/2013 1 2 12/12/2013
75170579 07/10/2013 1 1 15/11/2013
75170579 07/10/2013 1 3 10/06/2014
76506914 19/03/2012 3 4 08/08/2012
76506914 19/03/2012 3 1 28/06/2012
76506914 19/03/2012 3 1 19/04/2012
76506914 19/03/2012 3 4 29/05/2012
77966344 17/01/2012 2 3 14/03/2012
77966344 17/01/2012 2 2 03/05/2012
77966344 17/01/2012 2 1 05/04/2012
77966344 17/01/2012 2 3 01/06/2012
77966344 17/01/2012 2 2 01/09/2012
77966344 17/01/2012 2 4 07/07/2012
77966344 17/01/2012 2 1 01/08/2012
77966344 17/01/2012 2 3 04/10/2012
77966344 17/01/2012 2 1 03/11/2012
82867861 02/05/2011 3 1 03/02/2012
82985152 01/09/2011 2 2 02/07/2012
82985152 01/09/2011 2 2 01/06/2012
82985152 01/09/2011 2 2 02/04/2012
82985152 01/09/2011 2 2 02/05/2012
82985152 01/09/2011 2 2 02/01/2012
82985152 01/09/2011 2 3 01/02/2012
82985152 01/09/2011 2 3 01/03/2012
108172029 29/05/2011 1 3 02/02/2012
108172029 29/05/2011 1 3 09/03/2012
108279276 27/05/2011 1 1 08/03/2012
108279276 27/05/2011 1 2 06/01/2012
108279276 27/05/2011 1 3 03/02/2012
110186178 18/08/2011 1 3 11/01/2012
110186178 18/08/2011 1 3 09/02/2012
110186178 18/08/2011 1 4 13/03/2012
110186178 18/08/2011 1 4 11/06/2012
110186178 18/08/2011 1 4 16/04/2012
110186178 18/08/2011 1 1 14/05/2012
110206340 13/11/2011 1 1 29/08/2012
Hi
this is my data, I didn't use any coed, but I just tried to use the normal proc freq as pr * cow_id, but it doesn't work.
regards
@Barkamih wrote:
Hi all
I have data called fat, and it has variable PR and TEST DATE as well as COW ID.
Each cow has four test dates or more, and PR variable has four different levels.
My question is I want to know the average number of test dates per cow for each PR level.
someone told me it could be by using proc freq for cow id * pr, but I couldn't figure out that code
I hope you got my query
Regards
Ibrahim
"COW ID" is not normally acceptable as a SAS variable name, spaces are not allowed.
So first check on the names of your variables.
You should show the code you attempted and any notes or messages from the LOG when things aren't working correctly.
Copy the text from the log, open a code box one the forum using the {I} icon and paste the code and any messages.
thanks for your replay, I knew the space issue, what I'm looking is how to create the proper code for this question, I didn't use any code yet except the proc freq code as cow_id * pr, but it doesn't work, actually, it worked but I didn't get my needs.
thanks again
regards
this code just showing the frequency of cow_id, but I'm looking for the average number of cow_id of all data.
-
Example input data and example output for the given input really helps.
Here is an example of determining the average number of models of cars per make (or brand). You should have this data set to examine.
proc freq data=sashelp.cars noprint; tables make*type /out=makecount; run; proc means data=makecount mean; var count; run;
The first step counts how many times combinations of MAKE and TYPE appear in the data. In this case there is one record per MODEL.
Then average the resulting count. Which yields the average number of records for MAKE and type combinations.
I think that COWID would take the place of MAKE and TYPE would be your PR. Which would give the average number of records per cow and pr.
If you need something else, provide some small actual example data for input and the output you want for that input.
thank you soooooooo much my brother.
I got the answer from this code. this requirement will be the last thing I was looking for to finish my first paper for publication.
thanks again
I might need your help for the second paper, be always online hahahahah.
best regards
Brakamih
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.