I have Table A and Table B , I want desired output should be like Table C
Either Macro or datastep should be fine
thanks in advance
Post the sas code, NOT picture, nobody would like to type it for you if want help from others.
data a;
input id count dty;
cards;
1022 2 200
1022 2 600
6500 3 3
6500 3 50
6500 3 12
;
data b;
input id dt : date9.;
format dt date9.;
cards;
1022 25apr2018
1022 11jul2018
6500 08may2018
6500 31may2018
6500 20mar2018
;
data have;
merge a b;
by id;
run;
proc sql noprint;
select max(count) into : n
from (select count(*) as count from have group by id);
quit;
data want;
set have;
by id;
array dty_{&n};
array dt_{&n};
if first.id then n=0;
n+1;dty_{n}=dty;dt_{n}=dt;
drop dt n;
format dt_: date9.;
run;
Hi
It can be solved, but I have a couple of questions.
1.actuvally the count is 3 only by mistake it's edited to 2
2.please consider dataset a and b are same order
3.yes i want the numbered quantity/date pairs go to the respective to input dataset order
Post the sas code, NOT picture, nobody would like to type it for you if want help from others.
data a;
input id count dty;
cards;
1022 2 200
1022 2 600
6500 3 3
6500 3 50
6500 3 12
;
data b;
input id dt : date9.;
format dt date9.;
cards;
1022 25apr2018
1022 11jul2018
6500 08may2018
6500 31may2018
6500 20mar2018
;
data have;
merge a b;
by id;
run;
proc sql noprint;
select max(count) into : n
from (select count(*) as count from have group by id);
quit;
data want;
set have;
by id;
array dty_{&n};
array dt_{&n};
if first.id then n=0;
n+1;dty_{n}=dty;dt_{n}=dt;
drop dt n;
format dt_: date9.;
run;
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.