Anthony Martin
Anthony Martin

Reputation: 787

Number formatting in SAS : How to create a number list with 01, 02,

I am working with sas, and I have a program I have made I want to run on a series of databases which are indexed by 01, 02 until 95 in characters ! (they correspond to different geographical areas). I have created my program and would like to use a %lanc macro, but I would like to know if there is a better way thant


%lanc(area=01) 

%lanc(area=02)

...

%lanc(area=95)

My problem is therefore

  1. How to add a zero before a number with the DO TO proc (or is there a better way ?)
  2. How to convert these numbers in characters

Thanks

Upvotes: 0

Views: 401

Answers (1)

Chris J
Chris J

Reputation: 7769

Have a macro loop, create a copy of the loop counter but formatted to z2., then pass that into your macro call...

%MACRO LOOPER ;
  %DO LN = 1 %TO 95 ;
    %LET Z2 = %SYSFUNC(putn(&LN,z2.)) ; /* format &LN in z2. */
    %LANC(AREA=&Z2) ;
  %END ;
%MEND ;
%LOOPER ;

Upvotes: 2

Related Questions