DATA Step, Macro, Functions and more

number format: 0.0138054214235035 gets cut to -0.013805421

Reply
Regular Contributor
Posts: 229

number format: 0.0138054214235035 gets cut to -0.013805421

;;;-0.0138054214235035;-0.0774003621264634;-0.140738451940042;-0.202179585345623;-0.261822556355244;-0.322223016158721;-0.382933059864945;-0.443359874483071;-0.502726219354504;-0.561598550197106...

i got a seperated list of numbers (formatted as character 10000 field)

i use the folowwing code: but my numbers get cut to

-0.013805421

data edc_measures;

set edc(keep=curve_id V I);

array V_{500};

j = 1;

    do while (scan(V,j,';') NE '');

V_{j} = input(scan(V,j,';'),best32.);

j = j +1;

end;

run;

the format in the table says BEST12.??

Any help to get the numbers in full?

PROC Star
Posts: 7,363

number format: 0.0138054214235035 gets cut to -0.013805421

You're going to run into a numeric precision limitation anyway, but you are never setting the format.  Try:

data edc_measures;

  input v $32.;

  format VNum best32.;

  VNum= input(V,best32.);

  cards;

-0.0138054214235035

-0.0774003621264634

-0.140738451940042

-0.202179585345623

-0.261822556355244

-0.322223016158721

-0.382933059864945

-0.443359874483071

-0.502726219354504

-0.561598550197106

;

run;

Trusted Advisor
Posts: 1,300

number format: 0.0138054214235035 gets cut to -0.013805421

What are you planning to do with the numbers, you may want to consider storing as character, depending on your intention.

Frequent Contributor
Posts: 101

number format: 0.0138054214235035 gets cut to -0.013805421

The underlying value is not getting "cut" or truncated to 12 characters. SAS is only displaying 12 characters with the best12. format. For the list of numbers you have shown, add a format of, say, 23.18 to your data step for your V_ variables (format V_: 23.18Smiley Wink and you will see that SAS is storing more than you had thought. However, art297 does point out that you will have precision issues.

Contributor
Posts: 35

number format: 0.0138054214235035 gets cut to -0.013805421

He might be OK regarding precision issues depending on the hardware he is running on. I count 15 significant digits in all his numbers. According to http://support.sas.com/documentation/cdl/en/hostwin/63285/HTML/default/viewer.htm#numvar.htm with 8 byte numerics Windows does support 15 significant digits.

Ask a Question
Discussion stats
  • 4 replies
  • 189 views
  • 0 likes
  • 5 in conversation