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;
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.
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.
Good points.
However, I did not have any errors .
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.
Thanks so much JoshB!
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.
Much appreciated RW9!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: