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

I have 3 tables that I merged and it creates 3 separate rows because of various column titles, but I want it to create 1 row per strata. I attached what it looks like when I do the merge. I want it all on 1 row by the strata

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

Replace "set" with "merge".

View solution in original post

7 REPLIES 7
Reeza
Super User

Is example_table_date exactly like how your data is in SAS? Why do you post under different names?

tmcrouse
Calcite | Level 5


Yes it is. Because I am on my work computer right now and that is how they set up my desktop for the log in. The other is another log in from when I had another job but my current company will not let me use that. I have tried to log in on my home computer with this log in, but it is blocked. I guess employer related.

Haikuo
Onyx | Level 15

How did you merge them? show your code please.

tmcrouse
Calcite | Level 5

data pos_aggregates;

set  pos_tinofc pos_tinop pos_tinip;

by strata;

run;

1 table has the info for office, 1 table has the info for outpatient, 1 table has info for inpatient. I need to report on all the data but I am trying to figure out how to get it in 1 row for it all. I tried creating a table and appending. Did same thing as above code. Tried joins but it dropped records.

Haikuo
Onyx | Level 15

Replace "set" with "merge".

mkeintz
PROC Star

The SET statement INTERLEAVES observations, so the resulting data set has N1 (n records in pos_tinofc) + N2 (pos_tinop) + N3 (pos_tinip) records.

Now if the only variable in common in the 3 data sets is STRATA, then the MERGE statement will work (I assume as data set has no more than one record per stratum).

data want;
   merge pos_tinofc pos_tinop pos_tinip;
   by strata;
run;

If your 3 data sets have other variables in common, then let us know.

regards,

Mark

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
tmcrouse
Calcite | Level 5

Wish they would have the option in SAS forum to give correct answer to more than 1 person. I am an idiot. You know I knew this and for some reason I was just having one of those days. Thanks

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1434 views
  • 3 likes
  • 4 in conversation