Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Sarah Edgington" <sedging@ucla.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: use of tempfile |

Date |
Thu, 19 Apr 2012 11:51:02 -0700 |

Prakash, I don't think I have a clearer understanding than anyone else of what exact variables you want in your final data file. However, that may not matter if your problem really is with making the transition from saved data files to temp files. My advice is to write the code using standard data files first to get things working. Make sure you're getting exactly what you want. Then change the code to use tempfiles instead of permanent data files. I think the problem you're having right now is that you're trying to get 1 tempfile to stand in for 20 permanent datasets. You'll actually need 20 tempfiles. So every time you -save sales1_1.dta- you could instead say tempfile sales1_1 then save `sales1_1' Then when you go to merge you would merge using `sales1_1' You would then do the same for sales1_2, sales1_3, etc. If you can't get exactly what you want by writing the code using saved datasets then your problem really is with how to get the underlying structure you're looking for and not with the tempfile syntax. In that case you'll have to work through that issue first. Hope that helps. -Sarah -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Prakash Singh Sent: Thursday, April 19, 2012 8:54 AM To: statalist@hsphsun2.harvard.edu Subject: Re: st: use of tempfile Eric In the "before" data set I have list of variable say "n", now out of these n variables some variable are so kept in the data set that for each state_code they represent sales, export value of certain industry. My interest here to transform the data set in such a way that these sales and export value for the particular industry as separate variables. to put other way around I want to make my data free from state_code. so if the name of the data file is sales1.dta (before) Then using keep if command and renaming the numbers in state_code and other variable I have created data file assigning number identical to the category of state_code. the state_code variable is having 20 different values (category) and that's how I have sales1_1.dta to sales1_20.dta after use of keep if command. Now I have to merge these 20 newly created data set from "before" situation to get one final data set let us call it sales1_1_20.dta "after" situation so that sales, export of different industry will come beside each other as separate variable in one data file. common_id is the variable being able to uniquely identify the observation is sued to merge. I could write the code but it gives me unnecessary data file which I will not be using in analysis ( all other created data file baring sales1_1_20.dta). One obvious answer is that I can delete them once I have the final data file but then I thought there could some way using that I can bypass save command and that is the reason I have put tempfile as the subject of my query thread. Prakash * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: use of tempfile***From:*Prakash Singh <prakashbhu@gmail.com>

**References**:**st: use of tempfile***From:*Prakash Singh <prakashbhu@gmail.com>

**Re: st: use of tempfile***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: use of tempfile***From:*Prakash Singh <prakashbhu@gmail.com>

**Re: st: use of tempfile***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: use of tempfile***From:*Prakash Singh <prakashbhu@gmail.com>

**Re: st: use of tempfile***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: use of tempfile***From:*Prakash Singh <prakashbhu@gmail.com>

**Re: st: use of tempfile***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: use of tempfile***From:*Prakash Singh <prakashbhu@gmail.com>

**Re: st: use of tempfile***From:*Eric Booth <eric.a.booth@gmail.com>

**Re: st: use of tempfile***From:*Prakash Singh <prakashbhu@gmail.com>

- Prev by Date:
**Re: st: xt: unit-specific trends** - Next by Date:
**Re: st: Labeling different kinds of missing observations** - Previous by thread:
**Re: st: use of tempfile** - Next by thread:
**Re: st: use of tempfile** - Index(es):