Hi All,
I need to take an average of samples1 to 10 for respective treatment and replication and then would like to create a new variable of a treatment average (I have already sorted the data for replications and treatments). How can I achieve this by SAS coding, please?. It looks straight forward in excel but I am new to SAS and would like to learn it. Thank you in advance.
Replication (1-3) | Treatment (1-18) | Sample1-10 |
1 | 1 | values |
2 | 2 | |
3 | 3 |
Assuming your sample variables are named SAMPLE1, SAMPLE2, .... SAMPLE9 SAMPLE10, then
data want;
set have;
sample_average=mean(of sample1-sample10);
run;
Do you have ten variables, Sample1-Sample10 that you need an average for each line? Or are you calculating the average using data from multiple rows?
If 10 variables
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245914.htm
If multiple rows
http://support.sas.com/training/tutorial/studio/summary-statistics.html
It also depends on what you want for output, which you haven't specified.
Assuming your sample variables are named SAMPLE1, SAMPLE2, .... SAMPLE9 SAMPLE10, then
data want;
set have;
sample_average=mean(of sample1-sample10);
run;
Data transfomations can generally only be done in a DATA step or PROC SQL. DefinitelyNOT in a proc sort.
SAS is a procedure-oriented tool (some call it a language).
So ...
Then read something like "The Little SAS Book" to get the basics. (and run some SAS tutorials.).
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: