BookmarkSubscribeRSS Feed
R2211BAL
Calcite | Level 5

New to SAS.. Working on SAS Studio, Looking for SAS code for the following scenario

 

I have a data with the following variables

city A     city B    Miles    Price

a1             a2      1059     150

a1             a3      1089     150

a1             a4      1509     200

a1             a5       600       150

a1             a6      1989     200 

 

And I am looking to create an output like 

 

City A     Miles-Lowerlimit         Miles-Upperlimit                   Price

   a1           600                              1089                              150

   a1            509                             1989                              200

 

 

Thank You!!

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Do like this

 

data have;
input city_A $ city_B $ Miles Price;
datalines;
a1 a2 1059 150
a1 a3 1089 150
a1 a4 1509 200
a1 a5 600 150
a1 a6 1989 200
;

proc sql;
   create table want as
   select city_A
         ,min(Miles) as Miles_Lowerlimit
         ,max(Miles) as Miles_Upperlimit
         ,price
   from have
   group by city_A, price;
quit;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 875 views
  • 0 likes
  • 3 in conversation