BookmarkSubscribeRSS Feed
sas_learner_2013
Calcite | Level 5

Hi,

I am trying to automate my code.

I am getting errors. The same code works fine if called like this: %check_elig(method=eom,start='01jan2011'd, end='31may2011'd, state=nm);

22        

23         options fmtsearch=(auto WORK frmtdir library);

24         options mprint symbolgen mlogic pageno=1 nocenter;

25        

26         data _null_;

27         %let today=%sysfunc(today());

28         %let sdate= %str(%')%sysfunc(intnx(month,&today,-2,b),yymmdd10.)%str(%');

SYMBOLGEN:  Macro variable TODAY resolves to 19660

29         %let edate= %str(%')%sysfunc(intnx(month,&today,-1,e),yymmdd10.)%str(%');

SYMBOLGEN:  Macro variable TODAY resolves to 19660

30          call symput("bullet",'95'x);

31          call symput("tm",'AE'x);

32          call symput("copyright",'A9'x);

33         run;

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

     

34        

35        

36         %macro check_elig(method=,start=, end=, state=);

37        

38         data _null_;

39        

40          start=mdy(substr("&start",7,2),substr("&start",10,2),substr("&start",2,4));

2 The SAS System                                                                                     15:31 Tuesday, October 29, 2013

41          end=mdy(substr("&end",7,2),substr("&end",10,2),substr("&end",2,4));

42          call symput('months',intck('month', &start, &end));

43        

44        

45         run;

46        

47         data _null_;

48             %do i=0 %to &months;

49                 call symput("start_&i","'"||put(intnx('month', &start, &i, 'B'),yymmdd10.)||"'");

50                 call symput("end_&i","'"||put(intnx('month', &start, &i, 'E'),yymmdd10.)||"'");

51                 call symput("nondrug_&i","nondrug_"||strip(year(intnx('month', &start, &i, 'B')))||strip(put(month(intnx('month',

51       !  &start, &i, 'B')),z2.)));

52                 call symput("drug_&i","drug_"||strip(year(intnx('month', &start, &i, 'B')))||strip(put(month(intnx('month',

52       ! &start, &i, 'B')),z2.)));

53             %end;

54         run;

55        

56        

57         %mend check_elig;

58        

59         /*

60         %check_elig(method=eom,start='01jan2011'd, end='31may2011'd, state=nm);

61         */

62         %check_elig(method=eom,start=%unquote(&sdate), end=%unquote(&edate), state=nm);

MLOGIC(CHECK_ELIG):  Beginning execution.

SYMBOLGEN:  Macro variable SDATE resolves to '2013-08-01'

SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.

SYMBOLGEN:  Macro variable EDATE resolves to '2013-09-30'

SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been unquoted for printing.

MLOGIC(CHECK_ELIG):  Parameter METHOD has value eom

MLOGIC(CHECK_ELIG):  Parameter START has value '2013-08-01'

MLOGIC(CHECK_ELIG):  Parameter END has value '2013-09-30'

MLOGIC(CHECK_ELIG):  Parameter STATE has value nm

MPRINT(CHECK_ELIG):   data _null_;

SYMBOLGEN:  Macro variable START resolves to '2013-08-01'

SYMBOLGEN:  Macro variable START resolves to '2013-08-01'

SYMBOLGEN:  Macro variable START resolves to '2013-08-01'

MPRINT(CHECK_ELIG):   start=mdy(substr("'2013-08-01'",7,2),substr("'2013-08-01'",10,2),substr("'2013-08-01'",2,4));

SYMBOLGEN:  Macro variable END resolves to '2013-09-30'

SYMBOLGEN:  Macro variable END resolves to '2013-09-30'

SYMBOLGEN:  Macro variable END resolves to '2013-09-30'

MPRINT(CHECK_ELIG):   end=mdy(substr("'2013-09-30'",7,2),substr("'2013-09-30'",10,2),substr("'2013-09-30'",2,4));

SYMBOLGEN:  Macro variable START resolves to '2013-08-01'

SYMBOLGEN:  Macro variable END resolves to '2013-09-30'

MPRINT(CHECK_ELIG):   call symput('months',intck('month', '2013-08-01', '2013-09-30'));

MPRINT(CHECK_ELIG):   run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).

      62:29    62:50    62:72    62:104   62:123   62:143   62:2     62:2    

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).

      62:186  

NOTE: Invalid numeric data, '2013-08-01' , at line 62 column 2.

NOTE: Invalid numeric data, '2013-09-30' , at line 62 column 2.

start=19571 end=19631 _ERROR_=1 _N_=1

NOTE: Missing values were generated as a result of performing an operation on missing values.

      Each place is given by: (Number of times) at (Line):(Column).

      1 at 62:186  

NOTE: DATA statement used (Total process time):

3 The SAS System                                                                                     15:31 Tuesday, October 29, 2013

      real time           0.00 seconds

      cpu time            0.00 seconds

     

MPRINT(CHECK_ELIG):   data _null_;

SYMBOLGEN:  Macro variable MONTHS resolves to            .

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:

       &months

ERROR: The %TO value of the %DO I loop is invalid.

ERROR: The macro CHECK_ELIG will stop executing.

MLOGIC(CHECK_ELIG):  Ending execution.

63        

64         GOPTIONS NOACCESSIBLE;

65         %LET _CLIENTTASKLABEL=;

66         %LET _CLIENTPROJECTPATH=;

67         %LET _CLIENTPROJECTNAME=;

68         %LET _SASPROGRAMFILE=;

69        

70         ;*';*";*/;quit;run;

                     ____

                     180

ERROR 180-322: Statement is not valid or it is used out of proper order.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

     

71         ODS _ALL_ CLOSE;

72        

73        

74         QUIT; RUN;

75       

1 REPLY 1
saslearner_2013
Calcite | Level 5

Here I dont want to manually enter the dates.I am trying to completely automate the program.

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

CLI in SAS Viya

Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1024 views
  • 0 likes
  • 2 in conversation