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

Hi all,

Quick question:

I have 2 datasets (ds1 and ds2) and they have some common variables (like ID, site name etc.) and some uncommon variables (flags and markers I have created in each)

Is there any way using proc SQL to create a new dataset - that sources from ds1 and ds2 and computes sums from different variables?

Example:

DS1DS2
SiteUnitvarSiteUnitnum
AP10AP11
BO11BO11
BO11BO11
CI10CI10
CI10CI11
Final DS
SiteUnitvarsumnumsum
AP101
BO122
CI101
1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try this :

proc sql;

select * from

(select ID, Unit, sum(var) as sumvar from ds1 group by ID, Unit) natural join

(select ID, Unit, sum(num) as sumnum from ds2 group by ID, Unit);

quit;

PG

PG

View solution in original post

2 REPLIES 2
PGStats
Opal | Level 21

Try this :

proc sql;

select * from

(select ID, Unit, sum(var) as sumvar from ds1 group by ID, Unit) natural join

(select ID, Unit, sum(num) as sumnum from ds2 group by ID, Unit);

quit;

PG

PG
vomer
Obsidian | Level 7

thanks! that works wonderfully well.

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
  • 2 replies
  • 770 views
  • 0 likes
  • 2 in conversation