turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Print number in Decreasing order without proc sort

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-15-2016 09:32 AM

I have to print all the numbers less than 500 which is divisible by 7 in decreasing order WITHOUT using PROC SORT.

Accepted Solutions

Solution

11-15-2016
09:52 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to abhaykumar

11-15-2016 09:39 AM - edited 11-15-2016 09:42 AM

```
data test;
do i = 500 to 1 by -1;
if mod(i,7) = 0 then output;
end;
run;
proc print data=test noobs;
run;
```

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to abhaykumar

11-15-2016 09:39 AM

Why are you not allowed to use proc sort?

Are you allowed to use proc sort inside a call execute statement in the data step?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to draycut

11-15-2016 09:42 AM

To find some other method to solve this problem .

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to draycut

11-15-2016 09:42 AM

Proc sort is not been taught in class yet.

Solution

11-15-2016
09:52 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to abhaykumar

11-15-2016 09:39 AM - edited 11-15-2016 09:42 AM

```
data test;
do i = 500 to 1 by -1;
if mod(i,7) = 0 then output;
end;
run;
proc print data=test noobs;
run;
```

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to KurtBremser

11-15-2016 09:46 AM

Thank You sir, I was trying this way but I was not knowing about "By -1" thing. and I guess we can increase or decrease by any value by using "by -/+n" step, right?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to abhaykumar

11-15-2016 09:50 AM

abhaykumar wrote:

Thank You sir, I was trying this way but I was not knowing about "By -1" thing. and I guess we can increase or decrease by any value by using "by -/+n" step, right?

Correct. You can even use values with fractions.

Like

```
data test;
do i = 10 to 0 by -1.5;
output;
end;
run;
```

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers