A few colleagues and I were exchanging short snippets of SAS code that create Christmas trees and other holiday items by using the SAS DATA step to arrange ASCII characters. For example, the following DATA step (contributed by Udo Sglavo) creates a Christmas tree with ornaments and lights:
data _null_; put @11 '@'; do i=0 to 9; b=substr(repeat('*0',i),1,2*i+1); put @(11-i) b; end; put @10 '| |'; run; |
@ * *0* *0*0* *0*0*0* *0*0*0*0* *0*0*0*0*0* *0*0*0*0*0*0* *0*0*0*0*0*0*0* *0*0*0*0*0*0*0*0* *0*0*0*0*0*0*0*0*0* | | |
If you delete some unnecessary spaces, you can produce the Christmas tree in 90 characters. As a result, the DATA step is short enough to post on Twitter! So tweet the following message to all of your SAS friends!
#SAS XMas Tree http://bit.ly/uQELwe DATA;put@9'@';do i=0 to 8;b=substr(repeat('*0',i),1,2*i+1);put@(9-i)b;end; put@8'| |';RUN; |
Can you do better? One of my colleagues create a 76-character DATA step that produces a plain Christmas (with a star (*) on top) made entirely of the '0' character. Use the comments to post your favorite SAS code that spreads holiday cheer!
9 Comments
This is so much fun!!!!
Cool! I like the light bulb on the top.
You do not want to forget Hanukkah
data _null_;
put #1 @9 '(' #2 @1 '(' @9 '|';
j=3;
do i=' ','_';
do k=1 to 17;
c=ifc(not mod(k,2),i,'|');
put #j @k c @;
end;
j+1;
end;
put #j @8 '_|_';
run;
wow, great skill.....
Pingback: Iterated function systems and Barnsley’s fern in SAS - The DO Loop
Bolotin Yevgeniy pointed out that you can get under 90 characters if you replace SUBSTR with ||:
Really cool. Would be nice if you could randomly iterate with @ replaced by blanks to simulate blinking lights.
Ha-ha! Cool idea! I like it. :-)
Pingback: A normal Christmas tree - The DO Loop