BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User
If there was only one ID variables, That would be more simple.




data have;
infile cards truncover expandtabs;
input ID $	a1	s2	d3	f4	g5;
cards;
a1	0	2.56217	3.36783	3.53842	3.00214
s2	2.56217	0	2.87413	4.1333	3.60389
d3	3.36783	2.87413	0	2.46764	3.39893
f4	3.53842	4.1333	2.46764	0	2.97952
g5	3	    3	3.39893	2.97952	0
;
run;

%let dsid=%sysfunc(open(have));
%let nvars=%sysfunc(attrn(&dsid,nvars));
%let dsid=%sysfunc(close(&dsid));


data want;
 set have;
 array have{*} _numeric_;
 array id_{%eval(&nvars-1)} $ 32;
 do i=1 to dim(have);
  min=min(of have{*});
  idx=whichn(min,of have{*});
  id_{i}=vname(have{idx});
  have{idx}=.;
 end;
 keep id id_: ;
run;




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!

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
  • 16 replies
  • 1376 views
  • 3 likes
  • 3 in conversation