[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Dan Blanchette <[email protected]> |

To |
[email protected], [email protected] |

Subject |
RE: st: SAS equivalent command |

Date |
Fri, 9 Dec 2005 11:12:40 -0500 (EST) |

Yeah, that didn't make sense to me either. My explanation of the SAS code was a direct translation soit is following this step that your suggestion confused me. it does not make sense to simply concatenate three zero's onto var_logit in bi_meta.dta dataset and without SAS i cannot try to emulate the codes to visualise the SAS routines and adapt it for Stata.

whoever wrote the SAS code either intended to create 3 observations or accidentally pasted in the code

2 extra times.

****************************************************************

data bi_meta;

set meta;

/* creating the record for logit sensitivity */

dis = 1; non_dis = 0;

logit = log_sens; var_logit = var_log_sens;

rec=1;

output;

/* variable rec uniquely identifies each record */

/* writes the record holding sensitivity to the new dataset */

/* creating the record for logit sprecificity */

dis = 0; non_dis = 1;

logit = log_spec; var_logit = var_log_spec;

rec=1; output;

run;

****************************************************************

The above code creates 2 obs for every obs in the meta dataset. It's key to know that in SAS

one observation is run through the data step (from "data bi_meta;" to "run;") before the next

observation is processed. This concept hurts the Stata minded user since Stata processes all

observations before going on to the next command. You can emulate SAS by doing by-command

programming in Stata:

**********************************************************************************

(there are more effecient ways to do this, but I hope my example is understandable)

// initialize new vars

gen dis = .

gen non_dis = .

gen logit = .

gen var_logit = .

gen rec = .

// create an id variable based on the observation number "_n" so that you can do by-command programming

gen id = _n

// move this var to the front just for aethetics

order id

// now make 2 observations for every observation

expand 2

// Since Stata puts the new obs at the end, sort them back into order

sort id

// "if _n == 1" controls which of the 2 obs per group are being affected

by id: replace dis = 1 if _n == 1

by id: replace non_dis = 0 if _n == 1

by id: replace logit = log_sens if _n == 1

by id: replace var_logit = var_log_sens if _n == 1

by id: replace rec=1 if _n == 1

// now do the 2nd obs per group

by id: replace dis = 0 if _n == 2

by id: replace non_dis = 1 if _n == 2

by id: replace logit = log_spec if _n == 2

by id: replace var_logit = var_log_spec if _n == 2

by id: replace rec=1 if _n == 2

// you don't need this id variable drop id

**********************************************************************************

I really hope you are not having to translate bad SAS code.

Dan Blanchette

ITS Research Computing Group

University of North Carolina Chapel Hill

[email protected]

*

* 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/

**Follow-Ups**:**RE: st: SAS equivalent command***From:*"b. water" <[email protected]>

**RE: st: SAS equivalent command***From:*"b. water" <[email protected]>

- Prev by Date:
**Re: st: Floating relative risk** - Next by Date:
**Re: st: maximum likelihood procedures for oprobit** - Previous by thread:
**st: Kaplan Meier graph** - Next by thread:
**RE: st: SAS equivalent command** - Index(es):

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