Hi,
I have an existing table which contains a column listing IDs. However some of its cells contain an empty ID:
ID Age
XYS 29
60
STW 55
WTR 36
45
I would like to assign Alphanumeric IDs (20 digits) to these empty cells in order for them to be filled, but never repeated. This should also happen, irrespectively of the number of rows of the data set, as follows:
ID Age
XYSRW 29
RAND1 60
STWQT 55
WTRWQ 36
RAND2 45
Can somebody help me on this issue, with a simple statement that fills automatically these empty fields randomly?
Thank you so much.
Fernando
Hi,
data want (drop=cnt);
set have;
retain cnt;
if _n_=1 then cnt=1;
if missing(id) then do;
id=cats("RAND",put(cnt,best.));
cnt=cnt+1;
end;
run;
Hi,
data want (drop=cnt);
set have;
retain cnt;
if _n_=1 then cnt=1;
if missing(id) then do;
id=cats("RAND",put(cnt,best.));
cnt=cnt+1;
end;
run;
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!