CSULB_STAT475_handout17

CSULB_STAT475_handout17 - STAT 475 Chapter 14 MODIFYING...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
STAT 475 Chapter 14 MODIFYING NUMERIC VALUES WITH FUNCTIONS To return the integer portion of a numeric value, use the function INT . The syntax is int( argument ) where argument may be the name of a numeric variable, a constant, or an expression. Example. The numbers below are truncated by the INT function. data numbers; input values; integers=int(values); cards; 538.694226 6.24739599 466149.252 -27.5157162 ; proc print noobs; format values 11.7; run; The output is values integers 538.6942260 538 6.2473960 6 466149.2520 466149 -27.5157162 -27 To round value to the nearest specified decimal place, use the function ROUND . The syntax is round( argument , round-off unit ) The default round-off unit is one, and the value is rounded to the nearest integer. Example. The numbers below are rounded off the two decimal places by the function ROUND. data numbers; input values; rounded_values=round(values,0.01); cards; 538.694226 6.24739599 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
466149.252 -27.5157162 ; proc print noobs; format values 11.7; run; The output is rounded_ values values 538.6942260 538.69 6.2473960 6.25 466149.2520 466149.25 -27.5157162 -27.52 Chapter 11 CREATING AND MANAGING VARIABLES ACCUMULATING TOTALS It is often useful to create a variable that accumulates the values of another variable. The syntax is (in the DATA step) variable_name + expression ; where variable_name is the name of the accumulator variable . Its initial value is set to zero by default. Its value is retained from one DATA step execution to the next. Example. Consider the data set for the exercise example. ID Age ActLevel Sex Payment Due 2810 61 MOD F 34.00 2804 38 HIGH F 29.00 2807 42 LOW M 27.50 2816 26 HIGH M 20.25 2833 32 MOD F 15.50 2
Background image of page 2
ID Age ActLevel Sex Payment Due 2823 29 HIGH M 23.00 The following DATA step computes the total of payments due. The calculations are done iteratively. data exercise; input ID $ Age ActLevel $ Sex $ Payment; Total+Payment; cards; 2810 61 MOD F 34.00 2804 38 HIGH F 29.00 2807 42 LOW M 27.50 2816 26 HIGH M 20.25 2833 32 MOD F 15.50 2823 29 HIGH M 23.00 ; proc print noobs; run; The output is Act ID Age Level Sex Payment Total 2810
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

CSULB_STAT475_handout17 - STAT 475 Chapter 14 MODIFYING...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online