Hello,
I have this table
id variation
1 0.258
1 -0.53
2 0.563
2 -0.386
2 -0.568
I want to calculate the number of negative and positive variations by id. the table that I want
id variation count
1 positive 1
1 negatif 1
2 positive 1
2 negatif 2
Use a format.
proc format;
value pos_neg_fmt
low - 0 = 'Negative'
0 - high = 'Positive';
run;
proc freq data=have;
table ID*Variation / list;
format variation pos_neg_fmt.;
run;
@sasphd wrote:
Hello,
I have this table
id variation
1 0.258
1 -0.53
2 0.563
2 -0.386
2 -0.568
I want to calculate the number of negative and positive variations by id. the table that I want
id variation count
1 positive 1
1 negatif 1
2 positive 1
2 negatif 2
Thank you very much Reeza.
How I can do a z-test to test if the proportion of positive variation is equal between id 1 and 2?
please can you give the program pour z-test with Anova or ttest
I think should use Relative Risk . since it is really a contingency table.
@Rick_SAS wrote a blog about it before.
https://blogs.sas.com/content/iml/2017/07/05/test-equality-two-proportions-sas.html
https://blogs.sas.com/content/iml/2015/10/26/exact-tests-proc-freq.html
https://blogs.sas.com/content/iml/2015/08/21/she-ranger.html
data have; input id variation ; cards; 1 0.258 1 -0.53 2 0.563 2 -0.386 2 -0.568 ; data temp; set have; sign=sign(variation); run; proc freq data=temp noprint; table id*sign/list out=want; run; proc freq data=want; table id*sign/relrisk riskdiff chisq; weight count; run;
Just for completeness, where should exactly zero values fit?
in positive!
data have;
input id variation ;
cards;
1 0.258
1 -0.53
2 0.563
2 -0.386
2 -0.568
;
data temp;
set have;
sign=sign(variation);
run;
proc freq data=temp noprint;
table id*sign/list out=want;
run;
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.
Ready to level-up your skills? Choose your own adventure.