[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: WG: small problem with 'stack' command

From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: WG: small problem with 'stack' command
Date   Fri, 25 Sep 2009 13:23:39 +0200


Your post probably never made it to the list as it was in html-format.

Anyway, I cannot see what your problem really is. In my example, everything
seems to work just fine.

set obs 50
gen gp5=rnormal()
gen gp4=rnormal() in 1/48
gen gp3=rnormal() in 1/22
gen gp2=rnormal() in 1/36 
gen gp1=rnormal() in 1/48 

stack gp*, into(overall) /* 
*/ wide clear

list, noobs

//get summary of "overall"
summ overall, det


Von: Marwan Elkhoury [mailto:[email protected]] 
Gesendet: Freitag, 25. September 2009 12:31
An: [email protected]
Cc: [email protected]
Betreff: re: small problem with 'stack' command

dear statalist,

to clarify my previous post, I have 5 groups of countries, each one
containing a different number of observations, say group 1 has 48
observations, gp2 has 36 obs, gp3 has 22 obs, gp4 has 48 and gp5 has 50, so,
in total, I have 204 observations; for each group of countries, I have
estimated a score and a ranking.  Now, I need to stack up all these
countries together to get an overall score and estimate the overall ranking.

When I try to stack all the variables together, the 'stack' command cuts
each group to 22 observations, (least common number of observations in each
group), dropping the rest of observations.  thus, I end up with a group
having 5x22= 110 observations instead of 204 observations. that's the
problem.  Any idea how to adjust it ?

Copy of previous post:
dear statalist,

I have a minor problem with the 'stack' command in stata (stata 10 for  
windows xp).

I have 5 groups of countries of various size length which I want to  
stack into a single group of two variables, say, ctryg totrnk.

right now I have cntry_i, rnk_i, for i=1 to 5
and if I write the following:

stack cntry_1 rnk_1 cntry_2 rnk_2 cntry_3 rnk_3 cntry_4 rnk_4 cntry_5  
rnk_5, into(cntry_1 rnk_1) wide clear
ren cntry_1 cntryg
ren rnk_1 totrnk

It, in fact, creates two variables of size length the smallest of the  
size length of the groups and not stacking the entire number of  

what would be the easiest and smartest way of stacking this  
'unbalanced' group of variables, if any, to create one group of two  
variables from the 5 different groups ?

best regards,

Marwan Elkhoury

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index