BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

Hi ,

I have single record per ID

I want to make it to multiple records per ID as shown.

Could someone help me how to achieve this result???

Thanks

ID            dept1         dept2          startdate1                    startdate2                  enddate1                   enddate2         span1   span2

101         10thfloor                        22JUL14:21:21                 .                         26JUL14:14:06                 .                    3.6          0

102         9thfloor      9thfloor         19JUL14:17:48       24JUL14:13:19    24JUL14:10:06        29JUL14:18:59              4.6      5.2

WANT:

ID      LOCATION        IN                          OUT                          SATY

101       10thfloor      22JUL14:21:21      26JUL14:14:06            3.6

101                                .                             .                                0

102         9thfloor   19JUL14:17:48      24JUL14:10:06               4.6

102         9thfloor   24JUL14:13:19      29JUL14:18:59               5.2

2 REPLIES 2
Ksharp
Super User

OK. Give you an example .

data have;
input ID            dept1  : $20.       dept2   : $20.       startdate1     : datetime20.               startdate2    : datetime20.               enddate1     datetime20.               enddate2     datetime20.     span1   span2 ;
cards;
101         10thfloor          .              22JUL14:21:21                 .                         26JUL14:14:06                 .                    3.6          0
102         9thfloor      9thfloor         19JUL14:17:48       24JUL14:13:19    24JUL14:10:06        29JUL14:18:59              4.6      5.2
;
run;
data  want;
 set have;
 array d{*} $ dept:;
 array s{*} startdate:;
 array e{*} enddate:;
 array sp{*} span:;
 do i=1 to dim(d);
  location=d{i};
  in=s{i};
  out=e{i};
  stay=sp{i};
  output;
end;
keep id location in out stay;
run;
 

Xia Keshan

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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