/******************************************************************************
 * Programme : Macros SAS : Maîtrisez %SYSFUNC pour gérer la casse et automatisez enfin vos prévisualisations
 * Reference : DEMONS4F28
 * Source    : https://www.wearecas.eu/en/sampleCode/DEMONS4F28
 ******************************************************************************/

/* --- BLOC 1 --- */
%let make = volvo;

title "Bilar av mérket &make";
proc print data=sashelp.cars;
  where make="&make";
  var make model msrp;
run;

/*         __
          |  |
          |  |
        __|  |__
        \      /
         \    /
          \  /
           \/
*/

/* --- BLOC 2 --- */
%let make = volvo;

title "Bilar av mérket &make";
proc print data=sashelp.cars;
  where make="%propcase(&make)";
  var make model msrp;
run;

/*         __
          |  |
          |  |
        __|  |__
        \      /
         \    /
          \  /
           \/
*/

/* --- BLOC 3 --- */
title "Bilar av mérket &make";
proc print data=sashelp.cars;
  where make=propcase("&make");
  var make model msrp;
run;

/*         __
          |  |
          |  |
        __|  |__
        \      /
         \    /
          \  /
           \/
*/

/* --- BLOC 4 --- */
title "Bilar av mérket &make";
proc print data=sashelp.cars;
  where make="%sysfunc(propcase(&make))";
  var make model msrp;
run;

/*         __
          |  |
          |  |
        __|  |__
        \      /
         \    /
          \  /
           \/
*/

/* --- BLOC 5 --- */
%macro head(tabeller=, obs=5);
  %local i;
  %do i = 1 %to ANTALTABELLER;
    proc print data=%scan(&tabeller, &i, %str( ))(obs=&obs);
    run;
  %end;
%mend head;

/*         __
          |  |
          |  |
        __|  |__
        \      /
         \    /
          \  /
           \/
*/

/* --- BLOC 6 --- */
%macro head(tabeller=, obs=5);
  %local i t;
  %do i = 1 %to %sysfunc(countw(&tabeller, %str( )));
    %let t = %scan(&tabeller, &i, %str( ));
    title "Första &obs raderna i %upcase(&t)";
    proc print data=&t(obs=&obs);
    run;
  %end;
  title;
%mend head;

%head(tabeller=sashelp.class)
%head(tabeller=sashelp.cars sashelp.heart sashelp.shoes)

