Statalist


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

st: generating a tempfiles within a program for later use [version10]


From   "Beth Gifford" <[email protected]>
To   [email protected]
Subject   st: generating a tempfiles within a program for later use [version10]
Date   Sun, 6 Jan 2008 20:32:46 -0500

Hello all
I have a data base with many tables (they represent students within
schools and then provide additional details on students).
What I want to do is to have a program for each  table ( that labels &
recodes variables, etc) and that then creates a tempfile with a
dataset that I can use to do the merging.  I'm very close but the
tempfile gets overwritten when the next program runs.  Here is a
simplified example.  The problem is that the school temporary file is
overwritten by the student temporary file.  any suggestions?

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

program define p_school, rclass
clear
    odbc load, dsn("MS Access Database; DBQ=$dbname")
table("tblSchool") lowercase
    compress
     label define l_lea 1    "Alamance" 2    "Anson" 3    "Bertie" 4
     label val leaid l_lea
  save `0'
end

program define p_student
clear
    odbc load, dsn("MS Access Database; DBQ=$dbname")
table("tblStudent") lowercase
     label define l_gender 1 Missing 2 Male 3 Female
        label val gender l_gender
     save `0'
end

tempfile d_school
p_school `d_school'

tempfile d_student
p_student `d_student'
*
*   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