I have a feeling this is a super basic question, but I can't seem to find an answer online. I am working on a project where I needed to manipulate six individual datasets and then merge them together based on an ID number (PublicID). The individual manipulations all work fine, but I'm getting stuck on the final step of merging and exporting.
Here is my code:
/***** MERGE IT ALL TOGETHER! *****/ data WFR_AllData; set WFR_AllData; merge WFR_Certification WFR_CourseworkNEW WFR_DegreeNEW WFR_Demographics WFR_EmploymentNEW WFR_PDNEW; by PublicID; run; proc print data=WFR_AllData (obs = 10); run;
And here is the error message:
465 /***** MERGE IT ALL TOGETHER! *****/
466
467 data WFR_AllData;
468 set WFR_AllData;
ERROR: File WORK.WFR_ALLDATA.DATA does not exist.
469 merge WFR_Certification WFR_CourseworkNEW WFR_DegreeNEW WFR_Demographics
469! WFR_EmploymentNEW WFR_PDNEW;
470 by PublicID;
471 run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.WFR_ALLDATA may be incomplete. When this step was stopped there were
0 observations and 426 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
472
473 proc print data=WFR_AllData (obs = 10);
474 run;
NOTE: No observations in data set WORK.WFR_ALLDATA.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Am I missing a step? When I go to export the file (I just did this through the menu), it has a row of variable names but nothing else.
Thanks in advance for your help!
data WFR_AllData; merge WFR_AllData WFR_Certification WFR_CourseworkNEW WFR_DegreeNEW WFR_Demographics WFR_EmploymentNEW WFR_PDNEW; by PublicID; run;
would the corrected syntax above help?
Although i am not clear what you mean creating a blank dataset to merge everything
do you wanna merge(horizontal combine)
data want;
merge dtset1 dtsset2 dtsetn;
by id;
run;
or sorted append(stack one over another) aka interleave?
data want;
set dtset1 dtsset2 dtsetn;;
by id;
run;
Horizontal combine using merge. I was trying to create a new blank dataset (WFR_AllData) to merge everything into.
data WFR_AllData; merge WFR_AllData WFR_Certification WFR_CourseworkNEW WFR_DegreeNEW WFR_Demographics WFR_EmploymentNEW WFR_PDNEW; by PublicID; run;
would the corrected syntax above help?
Although i am not clear what you mean creating a blank dataset to merge everything
Considering the error message from your initial post you may not want:
WFR_AllData
in the MERGE statement either.
In general, it's not good practice to include the data set name to be the same as one of the input or MERGE data sets because you then overwrite that data set and its harder to debug and find errors. And if you have no way to recreate that input data set it's gone for good.
data want; *bad idea, it replaces WANT with new data, old data is lost;
set want;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.