Hello @POOJAA,
@POOJAA wrote:
I do know approach 1 is giving correct ans. But can anyone plz explain the logic why approach 2 is generating only 52 rows i.e and not 53 rows?
This is because approach 2 counts Wednesdays (weekday 4), not Tuesdays.
@POOJAA wrote:
Approach : 1 --> total tuesday are 53
if weekday(date) = 3 then tuesday_count + 1;
Approach : 2 --> total tuesday can be 52 as 52 rows are generated
Day=weekday(i);
...
where day=4;
There is another mistake in your code with no impact on the count, though:
@POOJAA wrote:
Approach : 2 --> total tuesday can be 52 as 52 rows are generated
Day=weekday(i);
...
format day downame3.;
The DOWNAMEw. format expects SAS date values, not weekday numbers 1 - 7. The latter would be interpreted as the date values '02JAN1960'd, ..., '08JAN1960'd, but those days were Saturday, ..., Friday, not Sunday, ..., Saturday, hence misleading labels. Apply the DOWNAME3. format to the date variable i, not variable day, to see the correct weekday names.
... View more