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

st: Using a SAS like Array procedure in STATA


From   Winfred Avogo <[email protected]>
To   [email protected]
Subject   st: Using a SAS like Array procedure in STATA
Date   Mon, 27 Jun 2005 14:13:08 -0700

Hi All,

 

I am working on Add health data in Stata 9 and wish to create a single measure of DISTRESS using 9 identified variables all on a scale of 0-3. I have tried STATA’s “generate” and “replace” command below but did not trust the results I obtained.

 

generate distress=.

replace distress=1 if h3sp5==0|h3sp6==0|rr_h3sp7==0|h3sp8==0|h3sp9==0|h3sp10==0|rr_h3sp11==0|h3sp12==0|h3sp13==0

replace distress=2 if h3sp5==1|h3sp6==1|rr_h3sp7==1|h3sp8==1|h3sp9==1|h3sp10==1|rr_h3sp11==1|h3sp12==1|h3sp13==1

replace distress=3 if h3sp5==2|h3sp6==2|rr_h3sp7==2|h3sp8==2|h3sp9==2|h3sp10==2|rr_h3sp11==2|h3sp12==2|h3sp13==2

replace distress=4 if h3sp5==3|h3sp6==3|rr_h3sp7==3|h3sp8==3|h3sp9==3|h3sp10==3|rr_h3sp11==3|h3sp12==3|h3sp13==3

 

I would be happy if I could obtain assistance to do this more efficiently. Will array code in STATA like is done in SAS be appropriate here.

 

Thanks

 

Winfred Avogo

 




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