Bookmark and Share

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

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

st: Need help with Stata Programming

From   Michael Stewart <>
To   statalist <>
Subject   st: Need help with Stata Programming
Date   Thu, 30 May 2013 14:52:11 -0400

Dear Statalist user ,
I need help with stat porgramming.
I am working with multiple datasets and with the  help of statalist
users, was able to figure out a way to use multiple datasets, do data
management tasks and save them under separate files
My current code is as follows

local ds1 "D:\_Dummy\multiple\1\auto_1.dta"
local ds2 "D:\_Dummy\multiple\2\auto_2.dta"
local ds3 "D:\_Dummy\multiple\3\auto_3.dta"
local all ds1 ds2 ds3
foreach x in `all'{
use ``x'',clear
include "D:\_Dummy\multiple\4\"
include "D:\_Dummy\multiple\5\"
save ``x''_new.dta,replace
I want to create a string variable  "year" which needs to be 2000 for
auto_1.dta, 2001 for auto_2.dta,2002 for auto_3.dta etc
Is could open each dataset and create it myself  before starting a  the loop.
But is there a way to create one OR more  variables with different
values for different datasets??  within a loop

Please let me know.

Thank you

Sincerely ,
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index