I have a level one variable called spid and a level two variable called opid. Using data from both spid and opid, I have created variables that characterize spid. Specifically, I used age from the one spid and ages from the 1-5 opid's listed for each spid to create dichotomous variables called peerintergen25 and information from the opid's to characterize them as family or friends to the spid and helpers or non-helpers to the spid. I also created a categorical variable that combines all of this information using the group command and subsequently created dummy variables of the different possible combinations from this categorical variable. For example, an spid with 2 opid's listed may have 1 opid with a 0 for peerintergen25, 1 for famorfriend, and 1 for helpsSP (similarly, it is a 1 in a categorical variable that has 8 combinations of these characteristics grouped together, and 1 in a dummy variable created of those 8 possible categories), while the other opid may have different combinations of these characteristics. I also used "egen spidflag = tag(spid)" to create a tag the first spid given that some spid's have 1 opid listed, and others have 5 opid's listed.
Without losing information from the different opid's, I would like to create variables simply at level one for each spid, which I cannot do using the spidflag (because it would only take information from the first opid). I have tried using the collapse command with (count) for variables that vary by opid (like peerintergen25, famorfriend, helpsSP, the 8-category variable, and the dummy variables of the 8-category variables) and (first) for variables that only apply to spid (like gender), but the output shows the same cross-tabs for every count variable created.
I realize I can use xtset and look at this as a panel, but I would like to use a regular logistic regression to understand the odds of having a 1 for peerintergen25, with the potential to stratify analyses by or control for whether or not the peerintergen25 0/1 status varies by famorfriend or helpsSP.
Without losing information from the different opid's, I would like to create variables simply at level one for each spid, which I cannot do using the spidflag (because it would only take information from the first opid). I have tried using the collapse command with (count) for variables that vary by opid (like peerintergen25, famorfriend, helpsSP, the 8-category variable, and the dummy variables of the 8-category variables) and (first) for variables that only apply to spid (like gender), but the output shows the same cross-tabs for every count variable created.
I realize I can use xtset and look at this as a panel, but I would like to use a regular logistic regression to understand the odds of having a 1 for peerintergen25, with the potential to stratify analyses by or control for whether or not the peerintergen25 0/1 status varies by famorfriend or helpsSP.
Comment