turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-27-2015 11:00 AM

Hi,

So I wrote a simulation program in proc IML. It works fine when the number of reps are low. However, when I run the full program, it crashes on me and I get this error message eventually:

ERROR: Permanent copy of file WORK.DAT.DATA was deleted.

ERROR: Cannot create data set WORK.DAT. [Permanent copy of file WORK.DAT.DATA was deleted.]

I am guessing I am reading and writing the work.dat file too many times? Any help would be appreciated. I pasted the program below (sorry a lot of the beginning is a really makeshift way of changing the seed for each condition - if anyone knows a more elegant way to change the seed for each condition and have it be a known value - I would appreciate info on that too! ).

PROC IML;

path = 'C:\';

*Specify the number of observations and simulate the data;

probmiss = .2;

rando = 352930;

nreps = 2000;

do lpath = 1 to 3;

do apath = 1 to 4;

do bpath = 1 to 4;

do samp = 1 to 4;

if lpath = 1 then lambda = .4;

if lpath = 2 then lambda = .6;

if lpath = 3 then lambda = .8;

if apath = 1 then alpha = 0;

if apath = 2 then alpha = .1;

if apath = 3 then alpha = .3;

if apath = 4 then alpha = .5;

if bpath = 1 then beta = 0;

if bpath = 2 then beta = .1;

if bpath = 3 then beta = .3;

if bpath = 4 then beta = .5;

if samp = 1 then nobs = 100;

if samp = 2 then nobs = 200;

if samp = 3 then nobs = 500;

if samp = 4 then nobs = 1000;

if lpath = 1 & apath = 1 & bpath = 1 & samp = 1 then seedcalc = rando+510;

if lpath = 1 & apath = 1 & bpath = 2 & samp = 1 then seedcalc = rando+610;

if lpath = 1 & apath = 1 & bpath = 3 & samp = 1 then seedcalc = rando+701;

if lpath = 1 & apath = 1 & bpath = 4 & samp = 1 then seedcalc = rando+801;

if lpath = 1 & apath = 2 & bpath = 1 & samp = 1 then seedcalc = rando+901;

*** HERE I TRUNCATED ALL THE COMBOS FOR ILLUSTRATION PURPOSES - the actual program has every permutation written out ;

PSIM = 1 - (alpha*alpha);

PSIY = 1 - (beta*beta);

LambdaE = 1 - (lambda*lambda);

*LambdaX;

LX = {1.00};

*LambdaY Matrix;

LY = {1 0, 0 0, 0 0, 0 1.00};

LY[2,1] = lambda;

LY[3,1] = lambda;

*Gamma Matrix, First row is a path, Second row is c' path;

GA = {0, 0};

GA [1,1] = alpha;

*Phi Covariance Matrix;

PH = {1};

*Psi Covariance Matrix;

PS = {0 0.00, 0.00 0};

PS [1,1] = PSIM;

PS [2,2] = PSIY;

*Theta Delta Matrix;

TD = {0};

*Theta Epsilon Matrix;

TE = {0.00 0.00 0 0.00,

0.00 0 0.00 0,

0 0.00 0 0.00,

0.00 0 0.00 0};

TE [2,2] = LambdaE;

TE [3,3] = LambdaE;

*Beta Matrix, Second Row First Column is b path;

B = {0.00 0.00, 0 0.00};

B[2,1] = Beta;

*Identity Matrix;

I = {1 0, 0 1};

COVY = LY*(INV(I-B))*(GA*PH*GA`+PS)*(INV(I-B`))*LY`+TE;

COVX = LX*PH*LX` + TD;

COVYX = LY*(INV(I-B))*GA*PH*LX`;

COVXY = LX*PH*GA`*(INV(I-B`))*LY`;

UPPER = COVX || COVXY;

LOWER = COVYX || COVY;

cov = UPPER // LOWER;

*We set the mean vector to zero;

means = j(5,1,0);

*Specify the random number seed;

call randseed(seedcalc);

do iteration = 1 to nreps;

*Draw sample from multivariate normal distribution;

sampledata = randnormal(nobs,means,cov);

*Make some values missing;

missingindicator = j(nobs,1,.);

call randgen(missingindicator,'Bernoulli',probmiss);

sampledata[loc(missingindicator = 1),2] = -999;

*Output data to SAS data set;

create dat from sampledata[colname={X M1 M2 M3 Y}];

append from sampledata;

close dat;

*Create filename;

file = path + "mplus_NOBS" + strip(char(nobs)) + "_MISS" + strip(char(probmiss))+ "_alpha" + strip(char(alpha))+ "_beta" +

strip(char(beta))+ "_lambda" + strip(char(lambda)) + "_iter" + strip(char(iteration)) + ".dat";

*Output SAS data set to .dat file;

submit file;

data _null_;

set dat;

file "&file";

put x m1 m2 m3 y;

run;

endsubmit;

end;

end; end; end; end;

quit;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to pushpin2002

01-27-2015 11:54 AM

Well - I think I figured it out! It had nothing to do with my IML program - my computer's virus software was deleting the Work file.