Website Worth

Total Pageviews

Saturday

Why does my SAS data keep disappearing?

In SAS 9.*, after you have opened your data file, you need to make a 'temporary' data file to work on it. This will help avoid any harm to the original data you may unintentionally make.

Most SAS beginners can create the temporary file. Let's say you've already opened a file called 'worker'. Now you want to make a file called work2 to work on.

SAS syntax:

 

data work2;

set worker;

run;

 

When looking at variables, you see the need to re-code one or more variables, to make them suitable for some type of analysis. But it has happened to many that after recoding, data disappears, or you just see only few observations in the data 'work2'.

If the mistake lies on your thinking that you need to open file 'work2', you may run this:

data work2;

run;

Then, you continue with command 'if' to re-code variables.

If you do this, the data disappears after recoding. The newly created variables have just overridden all data in work2.

The correct way to do is to keep everything in one. That is:

data work2;

set worker;

if......then;

if.......then;

run;

Here you have new data set work2, with new variables.