Selecting a person based on the characteristics of others in the household: Number of persons in the household is not known

This is an example of a program that selects a person into the sample if anyone in the household is foreign born.

This example does not require that there is a variable that provides a count of the number of persons in the household.

In this example, the number of foreign born persons is summed over a household (using household ID). This count is merged with the rest of the person record and records are then kept on the basis of the fbcount variable.

See for an example of a program that takes advantage of a variable that provides a count of the number of persons in the household.

*******************************************************************;
filename pums90  pipe 'zcat
/usr/data/public/us/government/pums/1990/5pct/tx48.Z
';
/* INPUT data */
data a;
   retain state persons fborn;
   infile pums90;
   input @1 type $1. @;
   if type='H' then do;
        input serial 2-8  state $11-12;
        fborn=0;
        return;
      end;
   else do;
    input relat 9-10  sex 11  age 15-16  pwgt 18-21  rpob 29-30;
        count=0;
        end;
   if rpob ge 51 then foreign=1; else foreign=0;
run;
   proc sort data=a; by serial;
run;
   proc means noprint data=a;
     by serial;
   var foreign;
   output out=sumdat sum(foreign)=fhhld;
   run;
   data new;
     merge a sumdat (keep=serial state fhhld);
     by serial;
run;
   data result;
     set new;
     if fhld eq 0 then delete;
   data out;
     set result;
   file ex4a;
   put serial 1-7  rpot 9-10  foreign 12-12  fhhld 14-15;
run;

NEW PSC blog

Recent resources, events, news

New Publications

Knodel et al. "Gendered Housework in Vietnam." PSC Research Report.

Couper. Designing Effective Web Surveys

Next Brown Bag

Monday, Oct 13
Jamie Jones
"Fertility & Risk Aversion on Utah Frontier"


W A R N I N G

If you are reading this, it may be that you are using rather old web browsing software that does not support modern international Web technology standards. For a better experience of the Web and this site in particular, please upgrade your web browser software today. The following are good choices: Firefox 2; Opera 9; Safari 3.