BookmarkSubscribeRSS Feed
RobertHB
Calcite | Level 5

Hello,

 

I'm new on SAS and I'd like to do this:

 

I have this three datasets:

 

Dataset01 (DS1):
Id  | Begin_date | End_date
d   |01jun2022   |10jun2022
b   |02jun2022   |06jun2022
c   |02jun2022   |07jun2022

 

Dataset02 (ds2):
Date       |
05/06/2021 |
06/06/2021 |

 

Dataset03 (ds3):
id |max_days |
a  |3        |
b  |3        |
c  |2        |
d  |2        |
e  |4        | 
f  |5        |
g  |2        |
h  |3        |
i  |4        |
j  |2        |
k  |4        |
l  |4        |
m  |3        |
n  |3        |
o  |5        |
p  |4        |
q  |3        |
r  |3        |

 

Output condition.a1: every day of the year is one row


Output condition.a2: each day must have 7 ids on the row

 

What i'd like to do is this:


a.Fill the variables with the ids from Dataset01, daily;

 

b.If the number of ids for one day is not enough, fill with ids from Dataset02

 

Condition.b1. can't repeat the same id on a day
Condition.b2. max number of times the id can fill the blanks before pass to next id: Dataset03.max_days
Condition.b3. days listed on Dataset02 do not count for the condition.b2 (above)


c.When the list of ids (Dataset03) is over, start again from the beggining.

 

Output wanted:

 

Date      |var_01  |var_02  |var_03  |var_04  |var_05  |var_06  |var_07  |
01jun2022 | d(DS1) | a(ds3) | b(ds3) | c(ds3) | e(ds3) | f(ds3) | g(ds3) |
02jun2022 | d(DS1) | b(DS1) | c(DS1) | a(ds3) | e(ds3) | f(ds3) | g(ds3) |
03jun2022 | d(DS1) | b(DS1) | c(DS1) | a(ds3) | e(ds3) | f(ds3) | h(ds3) |
04jun2022 | d(DS1) | b(DS1) | c(DS1) | e(ds3) | f(ds3) | h(ds3) | i(ds3) |
05jun2022 | d(DS1) | b(DS1) | c(DS1) |        |        |        |        |
06jun2022 | d(DS1) | b(DS1) | c(DS1) |        |        |        |        |
07jun2022 | d(DS1) | b(ds3) | c(DS1) | f(ds3) | h(ds3) | i(ds3) | j(ds3) |
08jun2022 | d(DS1) | b(ds3) | c(ds3) | i(ds3) | j(ds3) | k(ds3) | l(ds3) |
09jun2022 | d(DS1) | i(ds3) | k(ds3) | l(ds3) | m(ds3) | n(ds3) | o(ds3) |
10jun2022 | d(DS1) | k(ds3) | l(ds3) | m(ds3) | n(ds3) | o(ds3) | p(ds3) |

 

Tks

3 REPLIES 3
Tom
Super User Tom
Super User

I don't understand what you are trying to do.  What is the actual business problem that it trying to be solved by this?

Why are there ID numbers in two different datasets?

What is the difference between the ID numbers in the first dataset (can you give this dataset more meaningful names? that might help explain what role they are serving) and the ID numbers in the third dataset.

What is the role of the dates?  Why are there DATE variables in two of the input datasets?  What is the relationship between the input dates and the output dates?

RobertHB
Calcite | Level 5
Hello, tks for ur reply.

The business problem is: out of office schedule. I cant't have more than 7 employees off frim the office in one day.

Ids=employee id

Dataset01 is a vacation dataset, with the employee id, beginning and end period.

Dataset02 is the holiday and weekend list.

Dataset03 is the list of all employees with the number of home-office days (according their work contract). It's a looping list.

Tks.
DartRodrigo
Lapis Lazuli | Level 10
Maybe you should try a join then use Proc Transpose.

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!

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.

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