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

I am running into some issues getting PROC TABULATE to correctly count the frequency of my categorical variables. A snippet of the Log file and the output of both the PROC TABULATE (top table) and the PROC FREQ (bottom table of gender) are below. My code is as such: 

title 'Table 1. Child Demographics';
*Does not like ATEAM_AUTISM_TYPE --> Assess outside of True/False positives;
PROC TABULATE data = CLEANED.Analytic_Data;
 options fmtsearch = (OUTPUT);
 keyword n / style = [just=R];
 keyword pctn / style = [just=L];
 class ATEAM_AUTISM_YES_NO CHILD_GENDER ATEAM_AUTISM_TYPE ASD_DTEAM_COMORBID_YESNO;  
 classlev CHILD_GENDER ATEAM_AUTISM_TYPE ASD_DTEAM_COMORBID_YESNO/ s = [just=R];
 table (CHILD_GENDER = 'Sex of Child' ATEAM_AUTISM_TYPE = 'Type of Autism' ASD_DTEAM_COMORBID_YESNO = 'Comorbidity Present'),
       (ALL = 'All Data ~nn (%)' ATEAM_AUTISM_YES_NO = 'A Team Autism Diagnosis')*(n ='' * [style = [just=R cellwidth = 75] f = 8.2]
	    											  	      pctn ='' * [style = [just=L cellwidth = 80] f = paren.]) / box = 'Child Variables';
 format ATEAM_AUTISM_YES_NO asd_perc. CHILD_GENDER sex. ATEAM_AUTISM_TYPE $asdtype. ASD_DTEAM_COMORBID_YESNO yesno.;
RUN; *Not stratifying properly;

PROC FREQ data = WORK.Data2019;
 table ATEAM_AUTISM_YES_NO*(CHILD_GENDER ATEAM_AUTISM_TYPE ASD_DTEAM_COMORBID_YESNO);
 options fmtsearch = (OUTPUT);
 format ATEAM_AUTISM_YES_NO asd. CHILD_GENDER sex. ATEAM_AUTISM_TYPE $asdtype. ASD_DTEAM_COMORBID_YESNO yesno.;
run;

For whatever reason, false positive isn't showing up at all. Furthermore, the numbers calculated for overall and true positive don't even match the frequency table. I am unsure where SAS got these values nor why PROC TABULATE would produce different results from PROC FREQ. 

I used similar code formatting for continuous variables stratified for Autism diagnosis and got matching results to PROC MEANS. I am not sure why it works well with some and not others. Does anyone have any ideas what could be causing this issue? Thank you in advance.

 

 Table1_Problems.pngTable1_Log.png

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
PROC TABULATE automatically removes observations where any CLASS variable has a missing value. You can override that behavior by adding the MISSING option to the PROC statement.

View solution in original post

2 REPLIES 2
qoit
Pyrite | Level 9

Hard to say what's causing the issue unless one views the data portion of the dataset. Having said that, do you think that the ROW level of the TABLES statement of the tabulate procedure limiting the view, perhaps simplify it by only using one variable as below for a comparison with FREQ procedure:

 

 table CHILD_GENDER = 'Sex of Child',
       (ALL = 'All Data ~nn (%)' ATEAM_AUTISM_YES_NO = 'A Team Autism Diagnosis')*(n ='' * [style = [just=R cellwidth = 75] f = 8.2]
	    											  	      pctn ='' * [style = [just=L cellwidth = 80] f = paren.]) / box = 'Child Variables';

Alternatively, use REPORT procedure.

Astounding
PROC Star
PROC TABULATE automatically removes observations where any CLASS variable has a missing value. You can override that behavior by adding the MISSING option to the PROC statement.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1275 views
  • 1 like
  • 3 in conversation