Dear all,
assuming I have this dataset and I want to find the range of the ages.
If I want the range to be displayed like (23-94). How do I do that?
data have;
infile datalines truncover ;
input age;
datalines;
23
43
55
60
94
55
60
;
run
What do expect as result exactly?
Untested:
data want;
set have end=jobDone;
retain min max;
if _n_ = 1 then do;
min = 99999;
max = 0;
end;
min = min(min, age);
max = max(max, age);
if jobDone then do;
put min " - " max;
end;
run;
data have;
infile datalines truncover ;
input age;
datalines;
23
43
.
55
60
94
55
60
;
proc sql;
select cats('(',min(age),'-',max(age),')') as range label='#'
from have;
quit;
proc sql;
select min(age), "-", max(age)
from have;
quit;
@andreas_lds @Ksharp @Kurt_Bremser : Thankyou all for the reply, I will try that
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.