lundi 1 novembre 2021

how to apply macroin sas?

Submit the program shown below into the Editor window and examine the result.

    %macro id(num);

    proc print data=maps.algeria label noobs;

    var x y ;

    where id=#

    title "Projected Longitude and Latitudes for Id &num";

    run;

    %mend id;

    %id(2)

Modify the macro so it submits the PROC PRINT step only if the NUM parameter values between 1 and 9. If out of range the macro should write following message to the SAS log :

Id Number not found. And supplied value was: x

The value of x is the NUM parameter value.

· Resubmit the macro and call with valid and invalid parameter values and examine the results.

i have tried this

%macro ides(num);
%let id=%num;


%if  &num le 9 %then %do;

proc print data=maps.algeria label noobs;

var x y ;

where id=#

title "Projected Longitude and Latitudes for Id &num";

run;

%end;

%else

%do; 

%put Id Number not found. And supplied value was: #

run;

%end;

%mend ides;

Aucun commentaire:

Enregistrer un commentaire