Hi guys,
I hope you can help me with this:
I have 3 subjects: 1001, 1002 and 1003
Taking daily doses this periods of days:
subject start stop
1001. 10jun2021 17jun2021
1001 18jun2021 25jun2021
1001 26jun2021 02jul2021
1002 02feb2021 10feb2021
1002 11feb2021 3mar2021
1002 04mar2021 07mar2021
1003 10dec2021 15dec2021
1003 16dec2021 28dec2021
1003. 29dec2021 05jan2022
I want to create a dataset with daily records from the start de dose (start firs record=10jun2021) to the end of the dose (stop last record=02jul2021)...example for subject 1001
same for the other subjects...something like this
1001 10jun2021 10jun2021
1001 11jun2021. 11jun2021
1001 12jun2021 12jun2021
...
1001 02jul2021 02jul2021
1002 02eb2021 02feb2021
...
1002 07mar2021 07mar2021
1003 10dec2021 10dec2021
1003 ...
1003 05jan2022 05jan2022
It will be great if you can help me to generate these daily records.
Thanks in advance.
Cuan
Not sure what you gain by having two identical values.
Here is one way if your dates are actually SAS date values.
data have; input subject $ start :date9. stop :date9.; format start stop date9.; datalines; 1001 10jun2021 17jun2021 1001 18jun2021 25jun2021 1001 26jun2021 02jul2021 1002 02feb2021 10feb2021 1002 11feb2021 3mar2021 1002 04mar2021 07mar2021 1003 10dec2021 15dec2021 1003 16dec2021 28dec2021 1003 29dec2021 05jan2022 ; data want; set have; do daily=start to stop; output; end; format daily date9.; run;
Please note the use of data step code that can run to create a SAS data set to work with. The second data step adds a variable for every day of the start/stop periods. You could drop Start and stop if not wanted.
Not sure what you gain by having two identical values.
Here is one way if your dates are actually SAS date values.
data have; input subject $ start :date9. stop :date9.; format start stop date9.; datalines; 1001 10jun2021 17jun2021 1001 18jun2021 25jun2021 1001 26jun2021 02jul2021 1002 02feb2021 10feb2021 1002 11feb2021 3mar2021 1002 04mar2021 07mar2021 1003 10dec2021 15dec2021 1003 16dec2021 28dec2021 1003 29dec2021 05jan2022 ; data want; set have; do daily=start to stop; output; end; format daily date9.; run;
Please note the use of data step code that can run to create a SAS data set to work with. The second data step adds a variable for every day of the start/stop periods. You could drop Start and stop if not wanted.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.