Hi Everyone,
I am facing issue in data manipulation. Please help.
I have input file as
Input File
ID Date Flag1
ABC 24-Oct-21 23
ABC 23-Oct-21 45
ABC 8-Oct-21 33
XYZ 24-Jul-21 44
XYZ 25-Jul-21 98
Output require-
ID Date Flag1 Date2 Flag2 Date3 Flag3
ABC 24-Oct-21 23 23-Oct-21 45 8-Oct-21 33
XYZ 24-Jul-21 44 25-Jul-21 98
The most simple way is PROC SUMMARY.
data have; input (ID Date Flag1) (:$20.); cards; ABC 24-Oct-21 23 ABC 23-Oct-21 45 ABC 8-Oct-21 33 XYZ 24-Jul-21 44 XYZ 25-Jul-21 98 ; proc sql noprint; select max(n) into : n from (select count(*) as n from have group by id); quit; proc summary data=have; by id; output out=want idgroup(out[&n] (date flag1)=); run;
@Ajitesh wrote:
Hi Everyone,
I am facing issue in data manipulation. Please help.
I have input file as
Input File
ID Date Flag1
ABC 24-Oct-21 23
ABC 23-Oct-21 45
ABC 8-Oct-21 33
XYZ 24-Jul-21 44
XYZ 25-Jul-21 98
Output require-
ID Date Flag1 Date2 Flag2 Date3 Flag3
ABC 24-Oct-21 23 23-Oct-21 45 8-Oct-21 33
XYZ 24-Jul-21 44 25-Jul-21 98
Why do you need to do this? What analysis will you be performing on this data? Most times, analyses are easier performed on long data sets which you have, rather than wide data sets.
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.