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

Hi all!

 

If I write this to calculate a percentage in a data step,  where do I write the maxdec=2  so that percent_miss is only 2 decimals?

 

data gaq_4 (drop=_TYPE_ _FREQ_);
set gaq_1 (rename=(_FREQ_=Study_Population));
Percent_Miss=nmiss/Study_Population;

run;

 

Thank you!!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Are you asking how to round your results to 2 decimal places?

Use the ROUND() function.

Percent_Miss=round(nmiss/Study_Population, 0.01);

View solution in original post

2 REPLIES 2
Reeza
Super User

MAXDEC is only an option in PROC MEANS. 

 

You use a FORMAT or ROUND in a data step or SQL to limit the decimal places.

Tom
Super User Tom
Super User

Are you asking how to round your results to 2 decimal places?

Use the ROUND() function.

Percent_Miss=round(nmiss/Study_Population, 0.01);

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!

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
  • 4144 views
  • 0 likes
  • 3 in conversation