I'm not entirely sure what you are asking, but if you want to add 21 days to todays date, then simply do
data _null_;
todayplus21 = today() + 21;
format todayplus21 date9.;
put todayplus21;
run;
http://sasnrd.com/date-basics/
In Today date id freq dos lot total 06/22/17 06/23/17 06/24/17 06/25/17....
These cannot be variable names: 06/22/17 06/23/17 06/24/17 06/25/17
SAS variable names are _ or letter followed by _, letter or digit. NO / and cannot start with 0.
What values are you going to assign to those new variables? If you don't have a value why have the 21 additional variables?
This sounds like you may be trying to replicate some process that was originally done in a spreadsheet. If so you might be much better off describing your starting data and where this ends. Generally having data such as you propose with a separte column for each value of something (dates in this case) is MUCH better processed with a single variable to inicate that value group and another to hole the value.
There are many tools that work much better with data structured that way and then as a last step create a report with that group as a column heading.
It's not clear what you're asking here.
Please do not post the same question multiple times. I've merged them into one question now.
I'm not entirely sure what you are asking, but if you want to add 21 days to todays date, then simply do
data _null_;
todayplus21 = today() + 21;
format todayplus21 date9.;
put todayplus21;
run;
http://sasnrd.com/date-basics/
Before adding 21 days, you should describe your input:
what is the variable name that you want to add to it the 21 days? is it character or numeric type?
if numeric - is it a sas date? if not, what format is it (ddmmyyyy or yymmdd or date9. etc.)
The answer to your question will change according to your answers to those questions.
To get good answers you need to provide sufficient information in your question.
A very good way to provide such information is for you to post a SAS data step creating sample data and then you show us how your desired result should look like.
@PeterClemmensen already posted sample code. Have you looked into it and understood what it does? May be that's already the solution for you.
You need to create an array and then assign values.
array days(21) days1-days21;
do i=1 to 21;
days(i) = i + date;
end;
Statements like "it didn't work" without detailed explanation what you've done and what didn't work are not helpful.
1. Provide a fully working data step creating sample data
2. Explain what you want to do
3. Provide the desired output to illustrate what you've explained in words how the outcome should look like (as a SAS data step as well or just a table which lists the results you would like to get)
Once we understand what you have and what you need we can help you; else things will just go in circles waisting everbodys time.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.