BookmarkSubscribeRSS Feed
Ajitesh
Calcite | Level 5

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

2 REPLIES 2
Ksharp
Super User

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;
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 484 views
  • 0 likes
  • 3 in conversation