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