I have to print all the numbers less than 500 which is divisible by 7 in decreasing order WITHOUT using PROC SORT.
data test;
do i = 500 to 1 by -1;
if mod(i,7) = 0 then output;
end;
run;
proc print data=test noobs;
run;
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?
data test;
do i = 500 to 1 by -1;
if mod(i,7) = 0 then output;
end;
run;
proc print data=test noobs;
run;
@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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: