Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73265

Can I Autogenate savefile names using another another filename as a "base"

$
0
0
Hi
I'm new to Stata. I have been looking in the manual and the forums to see if I could find an answer my question, but unfortunately without luck. I hope you can help me.

I am currently importing delimited CSV files. I have made a do file that imports, makes a log file and saves the data twice - one save immediately after import and one save (under a different name) after Ive renamed and dropped a number of variables.

This means for every CSV file I import I get 2 data files that each need a name which is based on the CSV file I import (please see code below for clarification.)

Right now I am manually changeing the names of my save and log files. Its all the red numbers that I change to be the same as the green number. This works fine, but I need to import several hundred files so I would like to automate as much of the proces as possible.

Is there a way where I can autogenerate these names? If I could just write the number one time instead of 4 it would make a big difference.


clear
import delimited ".....Session102.csv", delimiter(tab) varnames(nonames) rowrange(6)
save "....\KGC_05_Session_102.dta", replace
capture log close
log using "....\KGC_05_Session_102log.txt", text replace
cd "....\KGC 05"
use KGC_05_Session_102.dta, clear
set more off
My do file runs.....and I end it with
save "KGC_05_Session_102_cleaned ", replace


I hope you can help me.
Thanks in advance.

Viewing all articles
Browse latest Browse all 73265

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>