data sat_2019;
file print ;
do saturdays_of_2019='1-Jan-19'd to '31-Dec-19'd;
if weekday(saturdays_of_2019)=7 then output;
end;
put saturdays_of_2019=;
format saturdays_of_2019 date9.;
stop;
run;
In the above i could not get complete dates output but in dataset i got perfect output
file print output like as following
saturday_of_2019 =01-Jan-2020
Please advised me
Regards,
Anand
If you apply some visual formatting to your code, you'll find the answer immediately:
data sat_2019;
file print;
do saturdays_of_2019 = '1-Jan-19'd to '31-Dec-19'd;
if weekday(saturdays_of_2019) = 7 then output;
end;
put saturdays_of_2019=;
format saturdays_of_2019 date9.;
stop;
run;
Your put statement comes after the end of the loop and is excuted only once, with the value that caused the iterative do loop to end.
Not understand
Your anawer
Compare your code (in the version I posted) with this:
data sat_2019;
file print;
do saturdays_of_2019 = '1-Jan-19'd to '31-Dec-19'd;
if weekday(saturdays_of_2019) = 7 then output;
put saturdays_of_2019=;
end;
format saturdays_of_2019 date9.;
run;
and you'll understand the answer.
Hi
Dataset output is difference
File print out is quite different
But i want both outputs are should be same
You can't make it "the same". The display of the file viewer window is dependent on the interface used. It's different between Display Manager, Enterprise Guide and SAS Studio. And with Studio, you have differences caused by the browser used.
Using file and put in a data step will create pure text, with no formatting whatsoever. If you want something fancy, use ODS and proc print or proc report.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.