BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pramenon1
Obsidian | Level 7

Hi, I am trying to create a 2x2 table and gather chisq. However, my treatment variable is by default showing up as 2 then 1 but i wanted it in ascending (1 then 2). My response variable is outputting correctly (1 then 0).

 

Here is my code:

 

PROC SORT data = dtanl.hivcancerdta;
by descending cancer;
RUN;

 

PROC FREQ data = dtanl.hivcancerdta order = data;
TABLE alcoh*cancer / chisq riskdiff or;
WHERE alcoh ^= 9;
RUN;

 

My output is:

 

2x2.PNG

Any information on what i am doing wrong would be appreciated!

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @pramenon1,

 

Add alcoh to the BY statement of the PROC SORT step:

by alcoh descending cancer;

Then your existing ORDER=DATA will sort rows and columns of the frequency table as desired.

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Use ORDER=INTERNAL

--
Paige Miller
pramenon1
Obsidian | Level 7

When I do that, cancer reverts to 0 then 1. I need it to be 1 then 0.

FreelanceReinh
Jade | Level 19

Hi @pramenon1,

 

Add alcoh to the BY statement of the PROC SORT step:

by alcoh descending cancer;

Then your existing ORDER=DATA will sort rows and columns of the frequency table as desired.

pramenon1
Obsidian | Level 7
Thank you! This worked perfectly!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 744 views
  • 2 likes
  • 3 in conversation