dearrest.blogg.se

Sas geodist example
Sas geodist example






sas geodist example

Suppose you wanted a count of the number of boysĪnd girls in the family. use, clear collapse (mean) avgage=age avgwt=wt (count) numkids=birth, by(famid) list famid avgage avgwt numkids use, clear collapse (mean) avgage=age avgwt=wt, by(famid) list famid avgage avgwtĪnd wt like the command above, and also computes numkids which is the count of the number of kids in each family (obtained by counting the number of observations with valid values ofīirth). Here we get the average forĪge and for wt all in the same command. We can request averages for more than one variable. use, clear collapse (mean) avgage=age, by(famid) list famid avgage The following collapse command does the exact same thing as above, except that the average ofĪge is named avgage and we have explicitly told the collapse command that we want it to compute the Use, clear collapse age, by(famid) list famid age The above collapse command was not very useful, but you can combine it with theĪnd then it creates one record for each family that contains the average age of the kids in the family. It collapses across all of the observations to make a single record with the average age of the kids. Use, clear list famid kidname birth age wt sexĬonsider the collapse command below.

#Sas geodist example how to#

We will use this file for showing how to collapse data across observations. (i.e., 1 is first), age wt and sex are the child’s age, weight and sex. Here is a file containing information about the kids in We will illustrate this using an example showing how you can collapse data across kids to make family level data. For example, you might have student data but you really want classroom data, or you might have weekly data but you want monthly data,Įtc. Sometimes you have data files that need to be collapsed to be useful to you.








Sas geodist example