Data: | ||
ID | Summer | Price |
2516 | A | 269 |
1678 | A | 240 |
20982 | B | 125 |
2516 | B | 452 |
20982 | A | 315 |
2516 | D | 804 |
20982 | D | 804 |
20982 | A | 200 |
WANT: | ||
ID | NEW_STRING | |
2516 | ABD | |
1678 | A | |
20982 | BADA | |
proc sql;
create index id on have(id);
quit;
data want;
do until(last.id);
set have;
by id;
length want $50;
want=cats(want,summer);
end;
keep id want;
run;
Hi @BaileyY Very straight forward
data have;
input ID Summer $ Price;
cards;
2516 A 269
1678 A 240
20982 B 125
2516 B 452
20982 A 315
2516 D 804
20982 D 804
20982 A 200
;
data _null_ ;
if _n_=1 then do;
dcl hash H () ;
h.definekey ("id") ;
h.definedata ("id","want") ;
h.definedone () ;
end;
set have end=z;
if h.find() ne 0 then want=Summer;
else want=cats(want,summer);
h.replace();
if z;
h.output(dataset:'want');
run;
proc sql;
create index id on have(id);
quit;
data want;
do until(last.id);
set have;
by id;
length want $50;
want=cats(want,summer);
end;
keep id want;
run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.