Statalist


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

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


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: generating a tempfiles within a program for later use [version10]
Date   Mon, 7 Jan 2008 15:08:59 -0500

Beth Gifford <[email protected]>:
Can you verify that the following experiment works on your system?  It
sounds like there is a problem in picking tempfile names.

program define p_school, rclass
 clear
 range x 0 1 2
 sort x
 save `0'
end
program define p_student
 clear
 range x 0 1 2
 sort x
 save `0'
end
tempfile d_school
p_school `d_school'
tempfile d_student
p_student `d_student'
merge x using `d_school'


On Jan 6, 2008 4:40 PM, Beth Gifford <[email protected]> wrote:
> 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