BookmarkSubscribeRSS Feed
Bhupinder
Calcite | Level 5
Hi,

I want to create subset of data based on one level of independent variable. I have used the following code to create subset of the data but it didn't work.

data spring07; set soils;
if crop = corn then delete;
run;

Is there any way to model with variable ne (^=). I did try but it is not working.

My second question is to calculate weighted means based on depths from that particular subset of data. I want to get weighted means of Phos variable based on depth as per following formula

Phos(weighted0-40) = (5*Phos1 + 5*Phos2 + 10*Phos3 + 20*Phos4)/40.

Phos(weighted0-20) = (5*Phos1 + 5*Phos2 + 10*Phos3)/20.

I don't know how I can do that because data has different other variables like Tillplc, Prate, Krate, and sampling location (in-row and between row).

Thanks, in advance!
Bhupinder
4 REPLIES 4
Bhupinder
Calcite | Level 5
At the start of experiment and at the end of each year (2007, 2008, and 2009) we measured soil parameters (phosphorus, potassium, calcium, and magnesium) to quantify the effect of treatments at different depths and different parts of the plots, aka, “loc” (IR-at the planting row; BR- between two planting rows). My second question in the original post came from the idea to quantify how much soil phosphorus increased or decreased for top 18 cm (weighted means of 0-5, 5-10, and 10-18) at the end of each year from initial values as well as from the first year. This can be calculate for locations separately and also for overall each plot.

Soybean experiment (2007 – 09) was planned as RCBD with split split plot arrangements of treatments with three replications. Three tillage treatments (NTBC, NTDP, and STDP) were done in three blocks as main treatments which I am calling as whole plots. Each block (whole plot) was divided into four parts to apply four phosphorus levels (0, 12, 24, and 36 kg/ha) which I am calling as sub-plots. These sub-plots were further divided into four parts to apply four potassium levels (0, 42, 84, and 168 kg/ha) which I am calling as sub-sub-plots or “PLOTS”. For year 2008 and 2009, we sampled all the plots but in the third year, we sampled plots only receiving 5 particular fertility treatments out of 16 combinations of P and K. Therefore, I have fertility (P-K) as category.

We sampled soil at two particular “locations” (within two planting rows and at the planting rows) and four depths (0-5, 5-10, 10-20, and 20-40) within PLOTS.

To handle this analysis, I need to subset this data for each MIXED model. I just want to keep only one data file to avoid confusion.

Thanks
Bhupinder
Ksharp
Super User
>Is there any way to model with variable ne (^=). I did try but it is not working.


Yes. proc mixed data=spring07(where crop ne 'corn' ) ......


>Phos(weighted0-40) = (5*Phos1 + 5*Phos2 + 10*Phos3 + 20*Phos4)/40.

You can just make hard code to get it.

data sprint0;
Phos_weighted= (5*Phos1 + 5*Phos2 + 10*Phos3 + 20*Phos4)/40.


BTW, the best way to get your answer is to give your origin data and what your output looks like.

Ksharp
ArtC
Rhodochrosite | Level 12
Notice that KSharp placed quotes around the literal 'corn'. This comparison is case sensitive.

Also observe the way that the variable is named in the equation. Naming conventions must be followed.
Ksharp
Super User
Dear Arther Carpenter:
I do not know to say what.


Ksharp Message was edited by: Ksharp

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 ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1297 views
  • 0 likes
  • 3 in conversation