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
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.