Hi All,
Can someone please explain to me how to create a variable that has values in increments of .01, and that ranges from -4 to 4. There should be no duplicate values.
For example,
-4.00
-3.99
-3.98
.
.
.
all the way to 4.00.
Thank you
Here's a recommendation that avoids some of the approximations produced by floating point arithmetic:
data want;
do n=-400 to 400;
newvar = n / 100;
output;
end;
keep newvar;
run;
Here's a recommendation that avoids some of the approximations produced by floating point arithmetic:
data want;
do n=-400 to 400;
newvar = n / 100;
output;
end;
keep newvar;
run;
Here one way to go:
data want;
do var=-4 to 4 by 0.1;
var=round(var,.00001);
output;
end;
run;
This approach will also achieve what I want. I only can accept one approach as the solution, however.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.