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;


 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 2 replies
  • 380 views
  • 0 likes
  • 3 in conversation