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
Create dummy variable to show change in certain timeframe of paneldataHi, I am working with paneldata and want to create a dummy variable that shows me if there is a cha…
Create for each time period the median of the 350 biggest valuesHello everyone, I am currently sitting on an issue regarding taking the median of the 350 highest v…
Graph with bold ylabelsHi all, I am trying to get bold ylabels in a time series graph. I had success only in xlabel , exam…
multiple imputation error after MI Estimate logistic regressionHello: Working on MI Everything works up to the MI estimate. See Error below Have been to the Stata …
ivreghdfe: how to first-stage regression predicted valueshello, i'm using ivreghdfe, and i'm interested in obtained predicted values of the endogenous variab…
Subscribe to:
Post Comments (Atom)
0 Response to Append within a loop
Post a Comment