I am trying to merge 2 data sets: ribs and shrimp. I am getting this error message.
Many of us will not download attachments. Please just include the code and the error in your message.
DATA New-Dataset-Name (OPTIONS);
MERGE Dataset-Name-1 (OPTIONS) Dataset-Name-2 (OPTIONS);
BY Variable(s);
RUN;
ERROR: Tables with 0 columns are not supported by this object. Work.BBQ cannot be opened. Do you want to select a different table to open?
@harveysarah0 wrote:
DATA New-Dataset-Name (OPTIONS); MERGE Dataset-Name-1 (OPTIONS) Dataset-Name-2 (OPTIONS); BY Variable(s); RUN;
This is not your actual code. We need to see the actual code that you ran which produced the error message.
data shrimp;
input City :$20. State :$3. Shrimp :$3.;
cards;
Baltimore MD Yes
Brooklyn NY No
Buffalo NY Yes
Harlem NY No
Newark NJ Yes
Rochester NY Yes
Stamford CT Yes
Syracuse NY Yes
Troy NY Yes
;
data ribs;
input City :$15. State :$2. Price;
cards;
Baltimore MD 10.95
Brooklyn NY 12.99
Buffalo NY 11.50
Harlem NY 12.50
Newark NJ 11.50
Rochester NY 10.95
Stamford CT 11.50
Syracuse NY 10.95
Troy NY 11.50
;
DATA BBQ Ribs (OPTIONS);
MERGE Ribs-1 (OPTIONS) Shrimp-2 (OPTIONS);
BY Variable(s);
RUN;
data shrimp;
input City :$20. State :$3. Shrimp :$3.;
cards;
Baltimore MD Yes
Brooklyn NY No
Buffalo NY Yes
Harlem NY No
Newark NJ Yes
Rochester NY Yes
Stamford CT Yes
Syracuse NY Yes
Troy NY Yes
;
data ribs;
input City :$15. State :$2. Price;
cards;
Baltimore MD 10.95
Brooklyn NY 12.99
Buffalo NY 11.50
Harlem NY 12.50
Newark NJ 11.50
Rochester NY 10.95
Stamford CT 11.50
Syracuse NY 10.95
Troy NY 11.50
;
DATA BBQ Ribs (OPTIONS);
MERGE Ribs-1 (OPTIONS) Shrimp-2 (OPTIONS);
BY Variable(s);
RUN;
You have program pieces that are entirely illegal.
(OPTIONS)
Cannot be part of a DATA step.
Ribs-1
Shrimp-2
These are not the names of your data sets, nor would they be legal as data set names if you attempted to create them.
Variable(s)
You have to actually name the variables, not imagine that SAS can figure out the right variable names.
This would be along the right lines:
DATA BBQ_Ribs;
MERGE Ribs Shrimp;
BY City State;
RUN;
Here's a tutorial on merging data, it covers your use case.
https://stats.idre.ucla.edu/sas/modules/match-merging-data-files-in-sas/
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 25. 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.