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.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.