BookmarkSubscribeRSS Feed
sasphd
Lapis Lazuli | Level 10

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

8 REPLIES 8
Reeza
Super User

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


 

sasphd
Lapis Lazuli | Level 10

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?

sasphd
Lapis Lazuli | Level 10

please can you give the program pour z-test with Anova or ttest

Ksharp
Super User

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;

 

ballardw
Super User

Just for completeness, where should exactly zero values fit?

Ksharp
Super User
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;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

Register now!

What is Bayesian Analysis?

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 393 views
  • 6 likes
  • 4 in conversation