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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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
  • 844 views
  • 0 likes
  • 3 in conversation