BookmarkSubscribeRSS Feed
frenchy_robert
Calcite | Level 5

Hello, i'm a beginner in SAS, and i have a problem with the function ROUND !

If I create toto table :

data toto;

input Annee Note Bac $; /* JAMAIS d'accent */

cards;

97 12.025 A

98 13.075 A

97 9.045  B

98 8.250  A

97 7.685  C

98 10.554 C

97 14.895 B

;

run;

then i want to print only Note var with rounding !

so :

title "Exemple d'édition de certaines variables";

proc print data=toto noobs round;

var note bac;

run;

it gives a 0.01 default rounding

but what if i want a 0.1 roundinf for example ?

i have so many syntax errors that i'm a bit upset now Smiley Sad

thanks Smiley Happy

5 REPLIES 5
PGStats
Opal | Level 21

You must associate a format to the variable, with the statement :

format note 6.1;

If you insert that statement in your datastep, the format will be permanently associated to the variable. If you put the format statement in the proc print call it will be associated only for the duration of the procedure.

PG

PG
TomKari
Onyx | Level 15

proc print data=toto noobs round;

format note 4.1;

var note bac;

frenchy_robert
Calcite | Level 5

Ok thanks to you two Smiley Happy

Now it works !

Can you explain me the meaning of 4.1 or 6.1 ? Is there a number for each rounding ?

PGStats
Opal | Level 21

in format 6.1, or more generally w.d, w is the width of the field and d is the number of decimals. Check

http://support.sas.com/documentation/cdl/en/leforinforref/63324/HTML/default/viewer.htm#n1n7bmvs1brl...

there are LOTS of formats available.

PG

PG
frenchy_robert
Calcite | Level 5

okay !

thanks for all

hu i have another question, but i guess i have to create another topic instead of asking here because this is about something else :smileygrin:

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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