Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: looping using two variables


From   "Jarrod P Franklin" <[email protected]>
To   [email protected]
Subject   st: looping using two variables
Date   Mon, 15 Mar 2004 14:20:09 +0000

Hi,

I am wondering if it is possible to do something like 'foreach' except 
over two different variables. I will clarify.

I want to run a loop  that opens a data file (say A) and generates a new 
variable (x1) which is equal to a variable already in the dataset. It will 
then open my original data set (say B) and merge B with A using 
another variable (y1). This is to allow me to compare the first instance 
of y (I have 21 different variables meaning the same thing but each 
combination is different for each patient ID), with the first instance of x. 

The problem is that each time the loop is run, I need to generate a new  
variable (x2, x3,...) which I can then take back to the data set B and 
tag on to the end using merge but with a different variable again (y2, 
y3,...).

I need to do this 21 times (which is why I am hoping to find a way of 
looping over two variables).

Note: x1=x2=...=x21, but y1,y2,...,y21 are all different (from each other 
and all x1 to x21).

Basically, each y has between 0 and ~300 ICD9 codes which I want to 
convert into ICD10 codes (found in x1, x2,...,x21) using a specific 
dataset I have acquired for this purpose. So what I am wanting is a 
corresponding ICD10 code for each occurrence of an ICD9 code so 
that x1 gives the corresponding icd10 code for each icd9 value in y1 
and so on for x2, y2, upto x21, y21.

I hope this is possible and that my explanation has been clear enough

Regards,

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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