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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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