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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 1014 views
  • 3 likes
  • 4 in conversation