Tips on how to Spherical Numbers in SAS (4 Examples)


You’ll be able to usefulness please see forms to spherical numbersĀ in SAS:

Form 1: Spherical to Then Integer

information new_data;
    i'm ready original_data;
    new_value = spherical(price);
run;

Form 2: Spherical to Particular Decimal Parks

information new_data;
    i'm ready original_data;
    new_value1 = spherical(price, .1); /*spherical to one decimal playground*/
    new_value2 = spherical(price, .01); /*spherical to two decimal playgrounds*/
    new_value3 = spherical(price, .001); /*spherical to three decimal playgrounds*/
run;

Form 3: Spherical All Values Unwell (Or Up) to Later Integer

information new_data;
    i'm ready original_data;
    new_value1 = flooring(price); /*spherical right down to nearest integer*/
    new_value2 = ceil(price); /*spherical as much as nearest integer*/
run;

Form 4: Spherical to Then More than one

information new_data;
    i'm ready original_data;
    new_value1 = spherical(price, 10); /*spherical to upcoming more than one of 10*/
    new_value2 = spherical(price, 100); /*spherical to upcoming more than one of 100*/
run;

Refer to examples display find out how to usefulness every form with please see dataset in SAS:

/*form dataset*/
information original_data;
    enter price;
    datalines;
0.33
0.9
1.2593
1.61
2.89
4.3
8.8
14.4286
18.2
51.4
;
run;

/*view dataset*/
proc print information=original_data;

Instance 1: Spherical to Then Integer

Refer to code displays find out how to spherical every price to the upcoming integer:

/*spherical to upcoming integer*/
information new_data;
    i'm ready original_data;
    new_value = spherical(price);
run;

/*view unused dataset*/
proc print information=new_data;

Instance 2: Spherical to Particular Decimal Parks

Refer to code displays find out how to around the values to a selected collection of decimal playgrounds:

information new_data;
    i'm ready original_data;
    new_value1 = spherical(price, .1); /*spherical to one decimal playground*/
    new_value2 = spherical(price, .01); /*spherical to two decimal playgrounds*/
    new_value3 = spherical(price, .001); /*spherical to three decimal playgrounds*/
run;

/*view unused dataset*/
proc print information=new_data;

Instance 3: Spherical All Values Unwell (Or Up) to Later Integer

Refer to code displays find out how to spherical all values i’m sick (or up) to the nearest integer the usage of the flooring() and ceil() purposes:

information new_data;
    i'm ready original_data;
    new_value1 = flooring(price); /*spherical right down to nearest integer*/
    new_value2 = ceil(price); /*spherical as much as nearest integer*/
run;

/*view unused dataset*/
proc print information=new_data;

Form 4: Spherical to Then More than one

Refer to code displays find out how to spherical all values to the upcoming more than one of a few price:

information new_data;
    i'm ready original_data;
    nearest10 = spherical(price, 10); /*spherical to upcoming more than one of 10*/
    nearest100 = spherical(price, 100); /*spherical to upcoming more than one of 100*/
run;

/*view unused dataset*/
proc print information=new_data;

Backup Assets

Refer to tutorials provide an explanation for find out how to carry out alternative regular duties in SAS:

Tips on how to Normalize Knowledge in SAS
Tips on how to Change Lacking Values with 0 in SAS
Tips on how to Take away Duplicates in SAS

Leave a Comment