BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rhilty
Obsidian | Level 7

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!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
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

View solution in original post

6 REPLIES 6
novinosrin
Tourmaline | Level 20

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;

 

rhilty
Obsidian | Level 7

Horizontal combine using merge. I was trying to create a new blank dataset (WFR_AllData) to merge everything into.

novinosrin
Tourmaline | Level 20
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

rhilty
Obsidian | Level 7
Thank you so much! The extra set statement must have been what was causing the error.
Reeza
Super User

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;

 

rhilty
Obsidian | Level 7
I took that out before I ran it, but thanks for flagging!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1103 views
  • 1 like
  • 3 in conversation