dear all
i have the data on interest rates in weekly frequency.
i would like to convert it into daily frequency by repeating the same rates throughout the week.
please suggest a SAS code to perform this function
my data is in the following format
| date | interest_rate |
| 30-Jun-2021 | 3.8898 |
| 07-Jul-2021 | 3.8419 |
| 14-Jul-2021 | 3.8099 |
| 20-Jul-2021 | 3.7744 |
| 28-Jul-2021 | 3.7299 |
i want output in the following format
| date | interest_rate |
| 30-Jun-2021 | 3.8898 |
| 01-Jul-2021 | 3.8898 |
| 02-Jul-2021 | 3.8898 |
| 03-Jul-2021 | 3.8898 |
| 04-Jul-2021 | 3.8898 |
| 05-Jul-2021 | 3.8898 |
| 06-Jul-2021 | 3.8898 |
| 07-Jul-2021 | 3.8419 |
| 08-Jul-2021 | 3.8419 |
| 09-Jul-2021 | 3.8419 |
| 10-Jul-2021 | 3.8419 |
| 11-Jul-2021 | 3.8419 |
| 12-Jul-2021 | 3.8419 |
| 13-Jul-2021 | 3.8419 |
| 14-Jul-2021 | 3.8099 |
| 15-Jul-2021 | 3.8099 |
| 16-Jul-2021 | 3.8099 |
| 17-Jul-2021 | 3.8099 |
| 18-Jul-2021 | 3.8099 |
| 19-Jul-2021 | 3.8099 |
| 20-Jul-2021 | 3.7744 |
| 21-Jul-2021 | 3.7744 |
| 22-Jul-2021 | 3.7744 |
| 23-Jul-2021 | 3.7744 |
| 24-Jul-2021 | 3.7744 |
| 25-Jul-2021 | 3.7744 |
| 26-Jul-2021 | 3.7744 |
| 27-Jul-2021 | 3.7744 |
| 28-Jul-2021 | 3.7299 |
| 29-Jul-2021 | 3.7299 |
| 30-Jul-2021 | 3.7299 |
| 31-Jul-2021 | 3.7299 |
| 01-Aug-2021 | 3.7299 |
| 02-Aug-2021 | 3.7299 |
| 03-Aug-2021 | 3.7299 |
thanking in advance
In a data step, OUTPUT each observation as is, then run a DO loop for date from date + 1 TO date + 6 with an additional OUTPUT.
In a data step, OUTPUT each observation as is, then run a DO loop for date from date + 1 TO date + 6 with an additional OUTPUT.
data have;
infile cards expandtabs;
input date : date11. interest_rate;
format date date11.;
cards;
30-Jun-2021 3.8898
07-Jul-2021 3.8419
14-Jul-2021 3.8099
20-Jul-2021 3.7744
28-Jul-2021 3.7299
;
data want;
merge have have(firstobs=2 keep=date rename=(date=_date));
output;
do date=date+1 to ifn(_date-1=.,date+6,_date-1);
output;
end;
drop _date;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
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.