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

Dear community,

 

I have a super simple question but could not figure out by my own, see below codes. Why I cannot get any record in data set "test"? This is so weird.

 

data A;
do v_gamma=0.7668,1,1.5,2,2.5,3,3.2749;
do v_rho=0 to 1 by 0.1;
do v_deltap=2,3,4,5;
do v_deltas=1,2,3,4,5;
v_tp1=0.5;
v_ts1=0.5;
v_alpha=0.05;
v_eps=1E-11;
output;
end;
end;
end;
end;
run;

data test;
set A;
where v_rho=0.8;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

see this paper:

https://support.sas.com/resources/papers/dealing-with-numeric-representation-error-in-sas-applicatio...

and try this:

data test;
set A;
where round(v_rho,0.1)=0.8;
run;
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

3 REPLIES 3
yabwon
Onyx | Level 15

see this paper:

https://support.sas.com/resources/papers/dealing-with-numeric-representation-error-in-sas-applicatio...

and try this:

data test;
set A;
where round(v_rho,0.1)=0.8;
run;
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



runningneptune
Fluorite | Level 6
Thank you mate! I learn something new.
vellad
Obsidian | Level 7

You can make it work using  

data test;
    set A;
    where round(v_rho,0.1)=0.8;
run;

The issue is related to rounding and the way computers internally store numeric values, specifically floating points.

See this thread for more info: Solved: Re: I meet with a problem of data values in do loo... - SAS Support Communities

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 832 views
  • 3 likes
  • 3 in conversation