DATA Step, Macro, Functions and more

"Table Cannot Be Opened"

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

"Table Cannot Be Opened"

Hi All,

 

I created a permanent SAS data set and I cannot open the the file.

 

The error reads 'The table "FINAL1.MERGED_DATA" cannot be opened because it does not contain any columns'

 

Any insight into why I cannot open the file would be most helpful and much appreciated.

Below please find my code:

data dataone;
infile '/folders/myfolders/DATA1.TXT' firstobs=7;
input DATE YYMMDD6. DAY BP CD DM;
run;

data datatwo;
infile '/folders/myfolders/DATA2.TXT' firstobs=7;
input DATE YYMMDD6. DAY JY SF;
run;

proc sort data=dataone;
by DATE;

proc sort data=datatwo;
by DATE;
run;

data merged_data;
format DATE YYMMDD6. DAY BP CD DM JY SF;
merge dataone datatwo;
by DATE;
run;

libname final1 '/folders/myfolders/final1';
data final1.merged_data;
run;


Accepted Solutions
Solution
‎10-28-2015 10:40 AM
Contributor
Posts: 55

Re: "Table Cannot Be Opened"

[ Edited ]

Assuming you don't have any errors before this point, you are missing the part of your last data step that writes out the table you created above.

 

libname final1 '/folders/myfolders/final1';
data final1.merged_data;
  set merged_data;
run;

If you do have other errors, please post.

View solution in original post


All Replies
Contributor
Posts: 45

Re: "Table Cannot Be Opened"

Did you get any other errors, for instance for you infile statements?

 

The data step merge probably also has an error. The format statement applies the YYMMDD6. format to your date variable but subsequently listing the other variables in the format statement without supplying a format might also cause an error.

 

Any error along the way will stop a data set from being created.

Occasional Contributor
Posts: 9

Re: "Table Cannot Be Opened"

Good points.

However, I did not have any errors .

 

 

Solution
‎10-28-2015 10:40 AM
Contributor
Posts: 55

Re: "Table Cannot Be Opened"

[ Edited ]

Assuming you don't have any errors before this point, you are missing the part of your last data step that writes out the table you created above.

 

libname final1 '/folders/myfolders/final1';
data final1.merged_data;
  set merged_data;
run;

If you do have other errors, please post.

Occasional Contributor
Posts: 9

Re: "Table Cannot Be Opened"

Thanks so much JoshB!

Super User
Super User
Posts: 7,430

Re: "Table Cannot Be Opened"

Yes, as JoshB has stated, because you are missing the set statement from the final datastep, SAS creates an empty dataset which has no observations or columns. Hence you get that error of no columns.

Occasional Contributor
Posts: 9

Re: "Table Cannot Be Opened"

Much appreciated RW9!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 1680 views
  • 4 likes
  • 4 in conversation