Hello,
I've used the following loop command to generate two data sets that I will be using to run a number of analysis:
The idea is to have two random samples of obs 200. I then plan to simulate how different statistical tests perform by simulation (2000 reps). I've only included 10 here to save computation time. The main issue I'm having is that I have to clear the x and y variables each time to run the loop, but I would like to add them to each other so that I have complete data set at the end of all the sample variables.
I tried using append in the loop (see below), but it just adds the same sample of 200 obs on top of each other
local a = 100
local c = 3
local b = 90
local d = 3
local obs = 200
local nsets = 10
set seed 987654321
forvalues i = 1/`nsets'{
clear
set obs `obs'
generate x = rnormal(`a',`c')
generate y =rnormal(`b',`d')
ttest x=y, unpaired
ttest x=y, unpaired unequal
save x, replace
save y, replace
*I tried using append here by adding:
*append using x
}
Thank you,
Don
Related Posts with Append within a loop
Stata seems to add spaces into path where there are none, wich leads to error messageDear statalist, I am using Stata/SE 15.1 for Mac. I am using a global to specify my path at the beg…
Taking Results from Tab2 and Using them to Generate/Recode a new variableI have a big dataset (1.7million obs) and I need to create contour plots by a member_id within the d…
STATA seems to add spaces into path where there are none although using double quotesDear statalist, I am using Stata/SE 15.1 for Mac. I am using a global to specify my path at the beg…
event-study (event-study2)Hi all, I am using Stata 16. My study: I have two periods that I will evaluate; 2008 - 2013 and th…
Linear interpolationHi! I have a variable called year in my dataset but this contains just the year 2006, 2009, 2011, 2…
Subscribe to:
Post Comments (Atom)
0 Response to Append within a loop
Post a Comment