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

The sas code below produces 4 decimal places output by default:

 

proc surveyfreq data=data6;

table AH_Zone*CHAS_NUTRN_1*CHAS_SEX/ CL chisq CV;

weight H_weight;

run;

 

Can someone help me reduce the output to 1 decimal place please!!

Thanks

Lordy

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

You can get hold of output tables data with ODS and then output them in whatever format you want with a datastep, proc SQL, proc Tabulate, proc Print or proc Report.  Use the statement ODS trace on;  before calling surveyfreq to see the names of output tables in the log. Then use ODS output wantedTable=myTable; to get a copy of the table.

PG

View solution in original post

6 REPLIES 6
PGStats
Opal | Level 21

You can get hold of output tables data with ODS and then output them in whatever format you want with a datastep, proc SQL, proc Tabulate, proc Print or proc Report.  Use the statement ODS trace on;  before calling surveyfreq to see the names of output tables in the log. Then use ODS output wantedTable=myTable; to get a copy of the table.

PG
Lordy
Obsidian | Level 7

Awesome it worked!!. However, it converted the missing values into 88 & 99 and I am still trying to figure out why?
Thanks alot

PGStats
Opal | Level 21

"it converted the missing values into 88 & 99" - That is unusual. Please post as a new question if the problem persists.

PG
Lordy
Obsidian | Level 7

This is the output I run to decrease to 1 decimal place

 

ods trace on;

proc surveyfreq data=data6;

table AH_Zone*new_CHAS_NUTRN_1*CHAS_SEX/ CL chisq CV;

weight AH_weight;

ods output CrossTabs=ZoneTable;

run;

proc print data=ZoneTable;

format percent 8.1

stderr 8.1

CL 8.1

CV 8.1;

run;

ballardw
Super User

Easiest is likely to be to pipe the output table to datasets and then you have all of the control of your favorite reporting procedures to modify formats, labels and appearance.

 

Add a statement similar to this for each table of output you want to reformat in the procedure call:

ods output <proc table name> = datasetnameyouwant;

 

The various table names are available in the online documentation for surveyfreq but you are likely looking for ChiSq

 

The other approach would be to modify the Surveyfreq table templates.

Lordy
Obsidian | Level 7

The ODS table name is Cross Tabs because it is an n-way table. I appreciate your help.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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