I looking to take three different exposures and tranpose their means to a single "site" variable. I'll post sample data to show what I mean. So I want to condense the site variable into one observation and tranpose the mean variable into three different variable for each exposure. For the real data I have a lot more IDs, sites, timepoints, etc. Any one have any ideas on how I would go about this? I was thinking about splitting up the data but wasn't sure of a good approach. Thanks for any help.
|What I have|
|What I Want|
|Date||Animal_ID||Site||Timepoint||Mean A||Mean B||Mean C|
Check the MERGE skill proposed by Me,Matt,Arthur.T .
data have; infile cards expandtabs truncover; input (Date Animal_ID Site Timepoint Exposure) ($) Mean; cards; 1-Jul 12 W1 Day1 a 13 1-Jul 12 C Day1 a 23 1-Jul 12 W1 Day1 b 25 1-Jul 12 C Day1 b 14 1-Jul 12 W1 Day1 c 23 1-Jul 12 C Day1 c 51 1-Jul 13 W1 Day1 a 23 1-Jul 13 C Day1 a 52 1-Jul 13 W1 Day1 b 36 1-Jul 13 C Day1 b 15 1-Jul 13 W1 Day1 c 29 1-Jul 13 C Day1 c 31 ; run; data temp(index=(xx=(Date Animal_ID Site Timepoint))); set have; by Date Animal_ID Timepoint Exposure notsorted; if first.Animal_ID then group=0; group+first.Exposure; run; proc sql; select distinct catt('temp(where=(group=',group,') rename=(Mean=Mean_',Exposure,'))') into : merge separated by ' ' from temp; quit; data want; merge &merge; by Date Animal_ID Site Timepoint; drop Exposure group; run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.