BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
TacoLover
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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;

View solution in original post

3 REPLIES 3
Astounding
PROC Star

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;
Patrick
Opal | Level 21

Here one way to go:

data want;
  do var=-4 to 4 by 0.1;
    var=round(var,.00001);
    output;
  end;
run;
TacoLover
Calcite | Level 5

This approach will also achieve what I want. I only can accept one approach as the solution, however.

sas-innovate-white.png

Special offer for SAS Communities members

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.

 

View the full agenda.

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
  • 977 views
  • 3 likes
  • 3 in conversation