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!!
proc sql;
create table want as
select
city_a,
price,
min(miles) as miles_low,
max(miles) as miles_high
from have
group by city_a, price;
quit;
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.