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

Hi, I am attempting to create this table in an ODS report for my Chi-Square results and I want to include the test name 'Chi-Square' under the column 'Test' in the table. However, I keep getting a blank cell beneath 'Test' in my table and I'm unsure how to alter my code to fix this. This is the code I am currently working with:

DATA ChiSqResults;
	SET ChiSqResults;
	KEEP STATISTIC DF VALUE PROB;
	LABEL Prob = "P-Value";
	IF STATISTIC = "Chi-Square";
		VALUE = ROUND(VALUE, 0.01);
		Prob = ROUND(PROB, 0.01);
	FORMAT VALUE F12.2
		Prob F12.2;
	RUN;

TITLE1 BOLD	'Chi-Square Test of Independence Results';
FOOTNOTE	"Created by HS";
PROC REPORT DATA = ChiSqResults;
	COLUMN	Test 
		("Statistical Results" DF Value Prob);
	LABEL Prob = 'P-Value';
	
	RUN;
TITLE;

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
James18
Obsidian | Level 7

Hi,

I believe you are having this issue because you are keeping the variable 'Statistic' in your Data step but in your Proc Report step, you are referring to 'Test' when you actually mean 'Statistic'. If you would like for the statistic variable to be renamed test, you could use a Define statement. I hope my code below helps!

PROC REPORT DATA = HypRslt.chisqresults  ;
COLUMN Statistic
("Statistical Results" DF Value Prob );
DEFINE Statistic / 'Test';
DEFINE Value / Format= 4.2;
DEFINE Prob / Format= 4.2 'P-Value';
RUN;

View solution in original post

2 REPLIES 2
James18
Obsidian | Level 7

Hi,

I believe you are having this issue because you are keeping the variable 'Statistic' in your Data step but in your Proc Report step, you are referring to 'Test' when you actually mean 'Statistic'. If you would like for the statistic variable to be renamed test, you could use a Define statement. I hope my code below helps!

PROC REPORT DATA = HypRslt.chisqresults  ;
COLUMN Statistic
("Statistical Results" DF Value Prob );
DEFINE Statistic / 'Test';
DEFINE Value / Format= 4.2;
DEFINE Prob / Format= 4.2 'P-Value';
RUN;
kaitlineolson7
Fluorite | Level 6

Hi,

It looks like 'Test' in your code should be replaced with Statistic, as that is where the Chi-Square option is held. Using DEFINE, as shown below, should solve your problem!

PROC REPORT DATA = dataset.ChiSqResults;
COLUMN Statistic ("Statistical Results" DF Value Prob );
DEFINE Statistic / 'Test';
DEFINE Prob / 'P-Value' FORMAT = 4.2 ;
DEFINE Value / FORMAT = 4.2;
FOOTNOTE "Created by HS";
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!

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