BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
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

5 REPLIES 5
Kurt_Bremser
Super User

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.

BrahmanandaRao
Lapis Lazuli | Level 10

Not understand 

Your anawer

Kurt_Bremser
Super User

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.

BrahmanandaRao
Lapis Lazuli | Level 10

Hi 

Dataset output is difference 

File print out is quite different 

But i want both outputs are should be same

Kurt_Bremser
Super User

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1124 views
  • 0 likes
  • 2 in conversation