DATA Step, Macro, Functions and more

Macro value is not resolved

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 81
Accepted Solution

Macro value is not resolved

Here is my simple coding.

 

DATA _NULL_;

/*

START=TRIM(LEFT(SUBSTR(SYSPARM(),1,8)));

END=TRIM(LEFT(SUBSTR(SYSPARM(),10,8)));

*/

 

START='MMDDYYYY';

END='MMDDYYYY';

IF START='MMDDYYYY' AND END='MMDDYYYY' THEN

DO;

PUT 'TEST1';

CURYEAR = YEAR(TODAY());

PREYEAR = CURYEAR -1 ;

 

CALL SYMPUT('CURYEAR',PUT(CURYEAR,4.));

CALL SYMPUT('PREYEAR',PUT(PREYEAR,4.));

END;

ELSE

DO;

PUT 'TEST2';

CALL SYMPUT('CURYEAR', SUBSTR(START,5));

CALL SYMPUT('PREYEAR', SUBSTR(END,5));

END;

%PUT &CURYEAR;

%PUT &PREYEAR;

Here is the part of the LOG, which says the &CURYEAR and &PREYEAR is not resloved. It is very strange , it didn't poped any error message.  I need somebody's help.. I am using SAS 8.2 on the mainfram.

 

 

57 %PUT &CURYEAR;

WARNING: APPARENT SYMBOLIC REFERENCE CURYEAR NOT RESOLVED.

&CURYEAR

58 %PUT &PREYEAR;

WARNING: APPARENT SYMBOLIC REFERENCE PREYEAR NOT RESOLVED.

&PREYEAR

59

60

61

62

63

64

65 ENDSAS;

TEST1

NOTE: THE DATA STATEMENT USED 0.01 CPU SECONDS AND 8635K.

NOTE: THE SAS SESSION USED 0.06 CPU SECONDS AND 8635K.

NOTE: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC USA 27513-2414

Thasnk very much for your help in advancel

TONY.


Accepted Solutions
Solution
‎12-30-2014 01:42 PM
Respected Advisor
Posts: 3,124

Re: Macro value is not resolved

After adding 'RUN' statement, it runs fine for me on SAS 9.4

View solution in original post


All Replies
Solution
‎12-30-2014 01:42 PM
Respected Advisor
Posts: 3,124

Re: Macro value is not resolved

After adding 'RUN' statement, it runs fine for me on SAS 9.4

Frequent Contributor
Frequent Contributor
Posts: 81

Re: Macro value is not resolved

Hi Hai.Kuo

Thanks very much . It worked after I add run  statment. Thanks very much. Saved my time.

Thanks

Tony

Super Contributor
Posts: 490

Re: Macro value is not resolved

data _null_;

START_d='MMDDYYYY';

END_d='MMDDYYYY';

IF START_d='MMDDYYYY' AND END_d='MMDDYYYY' THEN

DO;

  PUT 'TEST1';

  CURYEAR = YEAR(TODAY());

  PREYEAR = CURYEAR -1 ;

  CALL SYMPUT('CURYEAR',PUT(CURYEAR,4.));

  CALL SYMPUT('PREYEAR',PUT(PREYEAR,4.));

END;

ELSE DO;

  PUT 'TEST2';

  CALL SYMPUT('CURYEAR', SUBSTR(START_d,5));

  CALL SYMPUT('PREYEAR', SUBSTR(END_d,5));

END;

run;

%PUT &CURYEAR;

%PUT &PREYEAR;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 245 views
  • 3 likes
  • 3 in conversation