BookmarkSubscribeRSS Feed
ChingYee
Calcite | Level 5

/* Frequuency for Prices100 */
proc freq data=AddnewPrice;
TABLES Gender*Prices100
/chisq;
where Prices100 = "RM201-RM400";
run;

2 REPLIES 2
PaigeMiller
Diamond | Level 26

What is wrong with the code you show us?

--
Paige Miller
ballardw
Super User

You may want to describe what you are attempting and what you mean by "specfic variable"

 

I know that you likely don't like that your Log shows something like:

NOTE: No statistics are computed for Gender * Prices100 because Prices100 has less than 2 nonmissing levels.

You have restricted one of the variables to only allow one level, "RM101-RM400", and when you have a two-way chi-square the calculations just do not work that way as you are introducing a divide-by-zero condition.

 

You can run a chi-square on a single variable such as:

Proc freq data=sashelp.class;
   tables age /chisq;
run;

And the results reflect the levels of the single variable.

I suspect that you may have wanted if the question you wanted answered was "is the distribution of Gender the same/different when Prices100 has this specific value".

proc freq data=AddnewPrice;
   TABLES Gender
       /chisq;
    where Prices100 = "RM201-RM400";
run;

@ChingYee wrote:

/* Frequuency for Prices100 */
proc freq data=AddnewPrice;
TABLES Gender*Prices100
/chisq;
where Prices100 = "RM201-RM400";
run;


 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 845 views
  • 0 likes
  • 3 in conversation