I Have A Table Like This.

Cityno Cityname Mails
1 Bangalore 8km
2 Hsr Layout 20km
3 Mejistic 30km
4 Jayadeva 55km
5 Itpl 80km
6 Hebbal 115km

I Have Data Like This

I Want O/p Like This
Distance No.ofcity
0-50km 3
51-100km 2
101-150km 4

And So On

Answer Posted / anil

data abc;
set xyz;
count=1;
length Distance$ 10;
if mails<=50 then Distance='0-50';
else if 50 < mails <= 100 then Distance='51-100';
else if 100<mails <= 150 then Distance='101-150';
run;
proc print;
run;

proc sql;
select Distance,sum(count)as NO_OFCITY
from abc
group by Distance;
quit;

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we commit inside a trigger?

537


What are the various restrictions imposed on view in terms of dml?

509


how can we find the number of rows in a table using mysql? : Sql dba

570


How does stored procedure reduce network traffic?

531


What is a clob in sql?

556






What are tables and fields in the database?

541


Is it possible for a table to have more than one foreign key?

568


Can we call procedure in select statement?

509


What is difference between stored procedures and application procedures?

555


what is an alias command? : Sql dba

533


Is it possible to pass parameters to triggers?

555


What is varchar used for?

525


what are aggregate and scalar functions? : Sql dba

537


How do we accept inputs from user during runtime?

538


mention if it is possible to import data directly from t-sql commands without using sql server integration services? If yes, what are the commands? : Transact sql

548