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
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?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.