Help using Base SAS procedures

trying to get data into 1 row

Accepted Solution Solved
Reply
Contributor
Posts: 69
Accepted Solution

trying to get data into 1 row

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


Accepted Solutions
Solution
‎07-23-2013 05:33 PM
Respected Advisor
Posts: 3,156

Re: trying to get data into 1 row

Replace "set" with "merge".

View solution in original post


All Replies
Super User
Posts: 19,772

Re: trying to get data into 1 row

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

Contributor
Posts: 69

Re: trying to get data into 1 row


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.

Respected Advisor
Posts: 3,156

Re: trying to get data into 1 row

How did you merge them? show your code please.

Contributor
Posts: 69

Re: trying to get data into 1 row

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.

Solution
‎07-23-2013 05:33 PM
Respected Advisor
Posts: 3,156

Re: trying to get data into 1 row

Replace "set" with "merge".

Trusted Advisor
Posts: 1,018

Re: trying to get data into 1 row

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

Contributor
Posts: 69

Re: trying to get data into 1 row

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

🔒 This topic is solved and locked.

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

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