There is a datafile where the Options should be. What is it doing?

Viewed 13

I'm trying to learn SAS, clearly. I came across a strange format and I haven't found an explanation of it via google. What is datafile1 doing in the statement below? Isn't there supposed to be Options there?

data dataset1 datafile1; 
length col1 col2 $50.;
set c;
run; 
1 Answers

datafile1 is a second output dataset. The data step you list in the question simply makes two output datasets that are identical, which is generally uninteresting - but you could do something like this:

data male female all;
  set sashelp.class;
  if sex eq 'F' then output female;
  else if sex eq 'M' then output male;
  output all;
run;

That outputs different rows to different datasets.

Dataset options would go like this:

data want (keep=name age);
  set sashelp.class;
run;

They're compatible - you could do

data male(keep=name age) female(keep=name age) all(keep=name age sex);
  set sashelp.class;
  if sex eq 'F' then output female;
  else if sex eq 'M' then output male;
  output all;
run;
Related