Celebrate Christmas as a data scientist: Use SAS to play Jingle Bells

Jingle Bells, Jingle Bells, Jingle all the way……

2020 is an unprecedented year full of challenges, struggles and strives for every one. Now it is going to an end shortly, and we will have the joy and sadness mixed Christmas. We hope that the world will be getting better in 2021, and people can get over the hard time quickly.

Christmas is just at the corner now. Every one can celebrate it in his own way. But for data scientists, we can celebrate it in a special or a geeky way: we can use below SAS code to play the Jingle Bells music! Isn’t it cool? Try it and have fun!

%let pc=0.75; %macro df3(note,octave,length); select(&note); when("A") call sound(55*(2**&octave.),&length.*160*&pc.); when("A#") call sound(58*(2**&octave.),&length.*160*&pc.); when("Bb") call sound(58*(2**&octave.),&length.*160*&pc.); when("B") call sound(62*(2**&octave.),&length.*160*&pc.); when("C") call sound(65*(2**&octave.),&length.*160*&pc.); when("C#") call sound(69*(2**&octave.),&length.*160*&pc.); when("Db") call sound(69*(2**&octave.),&length.*160*&pc.); when("D") call sound(73.5*(2**&octave.),&length.*160*&pc.); when("D#") call sound(73.5*(2**&octave.),&length.*160*&pc.); when("Eb") call sound(78*(2**&octave.),&length.*160*&pc.); when("E") call sound(82*(2**&octave.),&length.*160*&pc.); when("F") call sound(87*(2**&octave.),&length.*160*&pc.); when("F#") call sound(92.5*(2**&octave.),&length.*160*&pc.); when("Gb") call sound(92.5*(2**&octave.),&length.*160*&pc.); when("G") call sound(98*(2**&octave.),&length.*160*&pc.); when("G#") call sound(104*(2**&octave.),&length.*160*&pc.); when("Ab") call sound(104*(2**&octave.),&length.*160*&pc.); when("R") call sleep((&length./3)*&pc.,1); otherwise; end; %mend; data notation; input x $ @@; note=translate(compress(x,,'kd'),'CDEFGABR','12345670'); octave=3; octave=octave+(note in ('A','B'))+count(compress(x,,'d'),'+')-count(compress(x,,'d'),'-'); cards; 5- 3 2 1 5- 0 0 0 5- 3 2 1 6- 0 0 0 6- 4 3 2 6- 0 0 0 5 5 4 2 3 0 0 0 5- 3 2 1 5- 0 0 0 5- 3 2 1 6- 0 0 0 6- 4 3 2 5 5 5 5 6 5 3 2 1 0 0 0 3 3 3 0 0 3 3 3 0 0 3 5 1 2 3 0 0 0 4 4 4 0 0 4 3 3 0 0 3 2 2 1 2 5+ 0 0 3 3 3 0 0 3 3 3 0 0 3 5 1 2 3 0 0 0 4 4 4 0 0 4 3 3 0 0 5 5 4 2 1 0 0 ; run; proc sql noprint; select note, octave into : note separated by '*', : octave separated by '*' from notation; quit; %macro music; data play; call execute('data _null_;'); %do i=1 %to %sysfunc(countw(&note,'*')); %df3("%scan(&note,&i,'*')",%scan(&octave,&i,'*'),1); %end; call execute('run;'); run; %mend; %music
Code language: SAS (sas)

Stay safe and Merry Christmas! Take care, everyone! Best wishes for you and your family!

Responses

error: Content is protected !!