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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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