BookmarkSubscribeRSS Feed
R_Win
Calcite | Level 5
I have a variables id and address

id address
1 main road
2 stret
3 bazar

now i want the min and max length of the observations in the variable address.
so finally the out should be like this min length(5) and max length(9)
2 REPLIES 2
Flip
Fluorite | Level 6
A simple SQL query can get you that:

proc sql;
select cats( 'min length(' , put(min(length(address)), best. -l), ')') ,
cats( 'max length(' , put(max(length(address)), best.-l), ')') from xxx;
quit;

One could also do it in a datastep :

data two;
set one end = eof;
retain big 0;
retain small 10000;
size = length(address);
big = max(big, size);
small = min(small, size);
if eof then output;
run;

Take your pick.
R_Win
Calcite | Level 5
Thanks for your Reply

Message was edited by: sas_user



data x;
input a$30.;
cards;
satish hjgjhgjhg
sam jhbhkjjjjkl lknjkl
ganesh
avb
;
run;


data y(drop=a);
retain min 100;
retain max 0;
set x end=s;
min=min(min,length(a));
max=max(max,length(a));
if s then output;
run;
proc print;
run; Message was edited by: sas_user

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 741 views
  • 0 likes
  • 2 in conversation