if a variable contain dates like "2015/01"---"2015/12" (yymm) ,How to add day to those dates,if them month is jan then 31 if the month is feb then 28 so on ...
Answer / Sona Singh
In SAS, you can create a dataset with the days for each month and then merge it with your original dataset. Here's an example:
```sas
data days;
do month = 1 to 12;
if (month = 2) then
days = 28;
else if ((month mod 4) = 0 and (month > 2)) then
days = 29;
else if (month in (1, 3, 5, 7, 8, 10, 12)) then
days = 31;
else
days = 30;
output;
end;
run;
data work.your_dataset;
merge your_dataset (rename=(date=from_date)) days;
set your_dataset;
date = mdys(year(from_date), month(from_date), day('01'd + ifn(month,31,28) + ifn(leap_year,1)));
run;
```
In this example, `leap_year` is a variable that indicates whether the year in `from_date` is a leap year.
| Is This Answer Correct ? | 0 Yes | 0 No |
What are the criticality that you have faced during your project in SAS?
i want for interview question & answer plz it need immediate send t my mail raviprakashmot@gmal.cm
What system options would you use to help debug a macro? : sas-macro
what is program data vector? : Sas-administrator
What are the functions done while Compilation...?
How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data?
How do you control the number of observations and/or variables read or written? Approximately what date is represented by the SAS date value of 730?
What are the applications primarily used by business analyst? : Sas-bi
Mention sas system options to debug sas macros.
what is function of retain statment
What SAS statements would you code to read an external raw data file to a DATA step?
how to import HTML files into SAS datasets?