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

st: AW: RE: Using data from other dataset for -gen-

From   "Kaulisch, Marc" <[email protected]>
To   <[email protected]>
Subject   st: AW: RE: Using data from other dataset for -gen-
Date   Fri, 29 Jan 2010 13:32:29 +0100


Thanks. I will have a look at this FAQ; but I got what I wanted...

The problem was to generate correct locals...

I found a solution (not translated):

Use dataset2:

levelsof adressiernr, local(adressid)

foreach gk of local adressid {
	gen xgki`gk' = gknr_i if adressiernr ==  `gk'
	gen xgks`gk' = gknr_s if adressiernr == `gk'
	gen xgkx`gk' = gknr_x if adressiernr == `gk'
	gen xkurz`gk' = kurzname if adressiernr == `gk'
	egen gki`gk' = max(xgki`gk')
	sort xgki`gk'
	gen gks`gk' = xgks`gk'[1]
	gen gkx`gk' = xgkx`gk'[1]
	gen kurz`gk' = xkurz`gk'[1]

foreach id of local adressid {
local gki`id' = gki`id' 
local gks`id' = gks`id'
local gkx`id' = gkx`id'
local kurzn`id' = kurz`id'

use Dataset 1

foreach gkinr of local adressid {
	egen koakt`gkx`gkinr'' = incss(kontext*), sub(`gkinr')
	la var koakt`gkx`gkinr'' "Aktueller Kontext `gks`gkinr'' `kurzn`gkinr''"
	notes koakt`gkx`gkinr'': Erstellt aus den aktuellen Kontexten mit `gkinr' / `tag'


-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von Nick Cox
Gesendet: Freitag, 29. Januar 2010 13:25
An: [email protected]
Betreff: st: RE: Using data from other dataset for -gen-

If you read in dataset 2, apply -levelsof-, and then read in dataset 1, the -local- will still be defined. 

Otherwise an FAQ by Kit Baum

may be of value. 

[email protected] 

Kaulisch, Marc

I have a problem I am not able to solve and it might be that someone else has a good solution at hand (using Stata 10 or 11).

My aim is to generate variables indicating if a person is in a certain context.
Dataset 1 looks like
Person_id context1 context2 context3 context4 context5

The context*-variables contain numerical values that identify certain institutions (institution_id). The real meaning/names of the institutions is given in the Dataset 2:
Institution_id short_name abbreviation institution_nr

At the end I would like to do the following for each in Dataset 1:

. egen co`institution_nr' = incss(context*), sub(`institution_id') . la var co`institution_nr' "Recent context `abbreviation' `shortname'"

But how do I get the information I need to do this in Dataset1 from Dataset 2?

I tried to do this with generating locals from dataset 2:
. levelsof institution_id, local(institution_id)

But then I loose the right connection between institution_id and the other vars in dataset2.

*   For searches and help try:

*   For searches and help try:

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