Desktop productivity for business analysts and programmers

How to UNION two results

Accepted Solution Solved
Reply
Contributor
Posts: 34
Accepted Solution

How to UNION two results

image.pngNeed to join Svc1 with Svc2 for TTLSVC

 

I have two query result sets as shown in example above.  I need to combine the results of each for a total.  I am having trouble finding documentation on how to do this in Enterprise Guide.  I am a novice with no coding experience.  I could also go back to the beginning and create a UNION on the two tables that each of these results were based on, but there are instances where I need the service types isolated, which is what I started off having them separate.  

 

Thoughts and suggestions are much appreciated!

 

Rita Yee

Project Engineer

FedEx Express

___________________________________
The fact that I ask for help simply means I am inexperienced and under-educated. Please don't assume I am incompetent and uneducated.

Accepted Solutions
Solution
Thursday
Super User
Posts: 22,823

Re: How to UNION two results

I would suggest going back, unioning the tables and generating the results by service types. When you're doing your queries or tasks, there's usually the ability to add a GROUP BY variable, put the service variable into that field and it'll get you the results within a single table.

 


@RPYee wrote:

image.pngNeed to join Svc1 with Svc2 for TTLSVC

 

I have two query result sets as shown in example above.  I need to combine the results of each for a total.  I am having trouble finding documentation on how to do this in Enterprise Guide.  I am a novice with no coding experience.  I could also go back to the beginning and create a UNION on the two tables that each of these results were based on, but there are instances where I need the service types isolated, which is what I started off having them separate.  

 

Thoughts and suggestions are much appreciated!

 

Rita Yee

Project Engineer

FedEx Express


 

 

View solution in original post


All Replies
Respected Advisor
Posts: 2,647

Re: How to UNION two results

[ Edited ]

You don't specifically state you want an SQL solution, so I give you a non-SQL solution.

 

Combine the two datasets into one, vertically. If you were programming, you would use the SET statement, I'm not sure the exact terminology if you are using Enterprise Guide (I think it might be "Append" or "Append Table". Then run PROC SUMMARY on the combined dataset, with Date as the CLASS variable.

--
Paige Miller
PROC Star
Posts: 1,296

Re: How to UNION two results

Please paste the values as plain text and not as screen shots/pics, doesn't help

 

data temp;

set service1 service2;

by month;

run;

 

proc means data=temp nway;

class month;

var _numeric_;

output out= want SUM=/AUTONAME; 

run;

Solution
Thursday
Super User
Posts: 22,823

Re: How to UNION two results

I would suggest going back, unioning the tables and generating the results by service types. When you're doing your queries or tasks, there's usually the ability to add a GROUP BY variable, put the service variable into that field and it'll get you the results within a single table.

 


@RPYee wrote:

image.pngNeed to join Svc1 with Svc2 for TTLSVC

 

I have two query result sets as shown in example above.  I need to combine the results of each for a total.  I am having trouble finding documentation on how to do this in Enterprise Guide.  I am a novice with no coding experience.  I could also go back to the beginning and create a UNION on the two tables that each of these results were based on, but there are instances where I need the service types isolated, which is what I started off having them separate.  

 

Thoughts and suggestions are much appreciated!

 

Rita Yee

Project Engineer

FedEx Express


 

 

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 106 views
  • 2 likes
  • 4 in conversation