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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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