Prat009 Tracker
https://communities.sas.com/kntur85557/tracker
Prat009 TrackerThu, 08 Aug 2024 04:29:54 GMT2024-08-08T04:29:54ZRe: How to count number of older siblings and the number of younger siblings?
https://communities.sas.com/t5/SAS-Programming/How-to-count-number-of-older-siblings-and-the-number-of-younger/m-p/467170#M119246
<P>Thanks a ton !</P><P>I had been trying to come up with a solution from past 4 days but I couldn't. Your code works just fine !</P>Sat, 02 Jun 2018 22:41:34 GMThttps://communities.sas.com/t5/SAS-Programming/How-to-count-number-of-older-siblings-and-the-number-of-younger/m-p/467170#M119246Prat0092018-06-02T22:41:34ZHow to count number of older siblings and the number of younger siblings?
https://communities.sas.com/t5/SAS-Programming/How-to-count-number-of-older-siblings-and-the-number-of-younger/m-p/466740#M119140
<P>Dataset description: </P><P>The local school district wants to survey all sixth grade students and their school-aged siblings. There are three different types of surveys: one for the sixth graders, one for their younger siblings, and one for their older siblings. The SAS data set called SCHOOLSURVEY contains data for all sixth graders in the three middle schools in the district (Rachael Carson, Green Valley, and Redwood Grove). The data set also includes data for all their siblings attending schools in the district, which can be linked back to the sixth grader by Family_ID.</P><P> </P><PRE><CODE>Fam_id Sdt_ID Sch Grade DOB DOB6th Age_Diff
90021 103699 4th 07/24/2004 01/26/2002 2.49
90021 127945 RG 6th 01/26/2002 01/26/2002 0
90021 149229 2nd 10/28/2005 01/26/2002 3.75
90053 109831 RC 6th 08/27/2002 08/27/2002 0
90053 122779 5th 08/28/2003 08/27/2002 1
90053 124617 8th 05/07/2000 08/27/2002 -2.31
90097 145616 4th 06/06/2004 12/20/2001 2.46
90097 164264 RC 6th 12/20/2001 12/20/2001 0
90112 147688 7th 10/11/2000 02/23/2002 -1.37
90112 171989 9th 06/27/1999 02/23/2002 -2.66
90112 197925 RG 6th 02/23/2002 02/23/2002 0 </CODE></PRE><P>Here, Fam_id = Family_id</P><P> Std_id = Student_id</P><P> Sch = School Code</P><P> DOB = Date of birth for all the grade students</P><P> DOB6th = Date of birth of the 6th grade student for a given <SPAN>Family_id</SPAN></P><P><SPAN> Agg_Diff = Age difference in years between 6th grade student and his/her siblings for a given Family_id</SPAN></P><P> </P><P>I want to count the number of older siblings and the number of younger siblings of the sixth grader in the family, and add these variables to the data set. It would be great if anyone can help me with this problem.</P><P> </P><P>Output should look like this :</P><PRE><CODE> Fam_id Sdt_ID Sch Grade DOB DOB6th Age_Diff Y_sib O_sib
90021 103699 4th 07/24/2004 01/26/2002 2.49
90021 127945 RG 6th 01/26/2002 01/26/2002 0 2 0
90021 149229 2nd 10/28/2005 01/26/2002 3.75
90053 109831 RC 6th 08/27/2002 08/27/2002 0 1 1
90053 122779 5th 08/28/2003 08/27/2002 1
90053 124617 8th 05/07/2000 08/27/2002 -2.31
90097 145616 4th 06/06/2004 12/20/2001 2.46
90097 164264 RC 6th 12/20/2001 12/20/2001 0 1 0
90112 147688 7th 10/11/2000 02/23/2002 -1.37
90112 171989 9th 06/27/1999 02/23/2002 -2.66
90112 197925 RG 6th 02/23/2002 02/23/2002 0 0 2</CODE></PRE><P> where, Y_sib = number of younger siblings of the sixth grader</P><P> O_sib = <SPAN>number of older siblings of the sixth grader</SPAN></P>Fri, 01 Jun 2018 04:40:09 GMThttps://communities.sas.com/t5/SAS-Programming/How-to-count-number-of-older-siblings-and-the-number-of-younger/m-p/466740#M119140Prat0092018-06-01T04:40:09ZRe: How to calculate mean across two variables in SAS?
https://communities.sas.com/t5/SAS-Programming/How-to-calculate-mean-across-two-variables-in-SAS/m-p/466704#M119121
Thanks for your response!Fri, 01 Jun 2018 02:23:19 GMThttps://communities.sas.com/t5/SAS-Programming/How-to-calculate-mean-across-two-variables-in-SAS/m-p/466704#M119121Prat0092018-06-01T02:23:19ZRe: How to calculate mean across two variables in SAS?
https://communities.sas.com/t5/SAS-Programming/How-to-calculate-mean-across-two-variables-in-SAS/m-p/466703#M119120
Thanks a lot ! Both of your solutions worked.Fri, 01 Jun 2018 02:22:04 GMThttps://communities.sas.com/t5/SAS-Programming/How-to-calculate-mean-across-two-variables-in-SAS/m-p/466703#M119120Prat0092018-06-01T02:22:04ZHow to calculate mean across two variables in SAS?
https://communities.sas.com/t5/SAS-Programming/How-to-calculate-mean-across-two-variables-in-SAS/m-p/466683#M119106
<P><SPAN>I have a data set which contains data on the average price of unleaded regular gasoline (per gallon), whole large eggs (per dozen), and whole milk (per gallon). The variables in this file are year, month, price, and type of commodity.</SPAN></P><P> </P><PRE><CODE>Year Month Price Commodity
2004 1 1.592 Gas
2004 2 1.672 Gas
2005 1 1.766 Gas
2005 2 1.833 Gas
2006 1 2.009 Gas
2006 2 2.041 Gas
2004 1 1.95 Egg
2004 2 1.979 Egg
2005 1 1.97 Egg
2005 2 1.951 Egg
2006 1 2.032 Egg
2006 2 2.21 Egg
2004 1 2.879 Milk
2004 2 2.814 Milk
2005 1 2.786 Milk
2005 2 2.906 Milk
2006 1 3.374 Milk
2006 2 3.574 Milk</CODE></PRE><P>Can anyone help me to create a data set that contains the average price per year for each commodity?</P><P>I am able to create a data set that contains the average price per year or per commodity, but unable to calculate average price per year for each commodity.</P><P>Note: I am using SAS 9.4 version</P><P> </P>Thu, 31 May 2018 23:36:05 GMThttps://communities.sas.com/t5/SAS-Programming/How-to-calculate-mean-across-two-variables-in-SAS/m-p/466683#M119106Prat0092018-05-31T23:36:05Z