Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

RE: st: serpentine sorting

From   Nick Cox <>
To   "''" <>
Subject   RE: st: serpentine sorting
Date   Wed, 12 Oct 2011 19:23:47 +0100

It's part of official Stata too. 


Steven Samuels

Check out the -fill- -egen- command by R. Mark Esman. 

net describe dm55, from(

On Oct 11, 2011, at 7:36 AM, Viktor Emonds wrote:

I am working on the construction of proper sampling frames for a research on the learning trajectories of minority and majority children in schools in Flanders. The target group are 3rd year students and we will select school establishments to conduct our study. 

Core variables of interest are the proportion of minority students in the 3rd year within an establishment (pforeign3), an implicit stratifier for educational tracks (typestrat), number of students (in quartiles) in the 3rd year in an establishment (studstrat), an implicit school net stratifier, an implicit dummy stratifier for high.low proportion of Turks in the region and a 4-category explicit stratifier on proportion of minority students in year 3 in the establishments (based on pforeignj3).

The idea is to create 4 sampling frames, one for each value of the explicit stratifier, and within each frame, sort on the implicit stratifiers (so we get nested sorting). At the lowest nesting level (in this case student size), we want to use the serpentine method and sort pforeignj3 ascending and descending in an alternating way over the values of studstrat. Unfortunately, gsort does not allow if commands, so something like gsort with - and + on even or odd values of studstrat doesn't work.

I tried sorting everything separately for each ethstrat-studstrat combination and then appending per ethnic stratum, but obviously, it doesn't work, because the nested sorting of the implciit stratifiers is disrupted and studstrat efefctively becomes a top-level stratifier. Any ideas on how to solve this? Thanks in advance!

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index