Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Temporary arrays, how to create

    thanks in advance for any help.

    I want to use clogit to calc some adjusted odds-ratios (risk of getting typhoid fever given stated exposures).
    Many of the exposures were 3 category (eg, 1 never, 2 sometimes, 3 often).
    The exposures, for ease of interpretation, I want to recode to binary (never, at-least-sometimes)
    and I want to do this in a batch way, so I want the batch file to run with temporary array variables, that self-destruct, I don't want to worry about dropping later, also I could document recoding tweaks quickly & as suits.
    I get impression what I want should be possible with stata local command, but either syntax defeats me or it's wrong command to use.

    eg, my algorithm in do-file is supposed to be
    ==================================
    use my-data-file
    log logfilename

    //next 3 lines not actual STATA commands, I don't understand what STATA commands to use
    recode exposureA into tempvarA, following rule (where exposure = 1, assign 0, else assign 1)
    recode exposureB into tempvarB , as prev
    recode exposureC into tempvarC , as prev

    clogit outcome tempvarA tempvarB tempvarC, group(groupnumbers) OR

    log close
    ========================

    and when that finishes running, tempvarA-C are all deleted b/c they are meant to be temporary, but the logfile will show me the ORs I want to be looking at.

    If you can follow that... can you advise how to make the tempvars?

    Mega thanks...!

    ps: while I'm at it, is there a way to see lots of examples of commands being used other than exhaustive google searches? I struggle to understand command syntax without seeing lots of working examples, the system helpfiles have few examples of working syntax

  • #2
    is there a way to see lots of examples of commands being used other than exhaustive google searches? I struggle to understand command syntax without seeing lots of working examples, the system helpfiles have few examples of working syntax
    Why Google when Stata provides comprehensive documentation as part of the installed software?

    When I began using Stata in a serious way, I started, as have others here, by reading my way through the Getting Started with Stata manual relevant to my setup. Chapter 18 then gives suggested further reading, much of which is in the Stata User's Guide, and I worked my way through much of that reading as well. There are a lot of examples to copy and paste into Stata's do-file editor to run yourself, and better yet, to experiment with changing the options to see how the results change.

    All of these manuals are included as PDFs in the Stata installation and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu. The objective in doing the reading was not so much to master Stata as to be sure I'd become familiar with a wide variety of important basic techniques, so that when the time came that I needed them, I might recall their existence, if not the full syntax, and know how to find out more about them in the help files and PDF manuals.

    Stata supplies exceptionally good documentation that amply repays the time spent studying it - there's just a lot of it. The path I followed surfaces the things you need to know to get started in a hurry and to work effectively.

    Comment


    • #3
      Ah darn, so heaps of RTFM really is the only way to find answers to narrow syntax questions? What a shame.
      I'm sure that reading the entire manual is very sensible if you use STATA more than once a year, obvs.

      Anyway, can anyone suggest how to generate temporary arrays? I'd be ever so grateful.
      So far I can only find syntax examples of using local & tempvar to create single scalar values (not array) but I get vague impression that an array might be possible. At very least I need to discover what command to research. Will keep searching.
      I can resort to kludge of algorithm using variables that I gen & drop, but seems like a more elegant solution ought to exist.
      Mega thanks!

      Comment


      • #4
        Code:
        tempvar A B C 
        gen `A' = ....
        gen `B' = ... 
        gen `C' = ...

        Comment

        Working...
        X