BookmarkSubscribeRSS Feed
pp2014
Fluorite | Level 6

I have the following data

 

data have;

input id $2. call_dt mmddyy10. hr $6.;

cards;

12 10/06/2015 10 am

12 10/06/2015 12 pm

12 10/06/2015 2 pm

12 10/06/2015 5 pm

 

I want the following output with missing hours added to the final output:

 

id       call_dt           hr

 

12 10/06/2015   10 am

12 10/06/2015   11 am

12 10/06/2015   12 pm

12 10/06/2015     1 pm

12 10/06/2015     2 pm

12 10/06/2015     3 pm

12 10/06/2015     4 pm

12 10/06/2015     5 pm

 

Any help will be greatly appreciated...

1 REPLY 1
Astounding
PROC Star

Assuming nothing is being left to the imagination (such as the presence of additional variables), the easiest way might be:

 

proc sort data=have (keep=id call_dt) nodupkey;

   by id call_dt;

run;

 

data want;

set have;

do hr = '10 am', '11 am', '12 pm', ' 1 pm', ' 2 pm', ' 3 pm', ' 4 pm', ' 5 pm';

   output;

end;

run;

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
  • 1 reply
  • 1064 views
  • 0 likes
  • 2 in conversation