View previous topic :: View next topic
|
Author |
Message |
Subbulakshmi yogesh
New User
Joined: 28 Sep 2011 Posts: 8 Location: india
|
|
|
|
hi i am creating a Global variable and trying to use that global variable inside one data step. its not getting resolved. code below,
%GLOBAL NUM_SPA;
DATA _NULL_;
...
CALL SYMPUT('NUM_SPA',ROUND(NUM_VAL));
RUN ;
DATA DD2.DATEVT;
SET MRG_EVNT_DATE;
%MACRO MOST_RECENT_SPA ;
%PUT 'CHECK NUMSPA :' &NUMSPA;
SPA_Date_Last = max(SPA_Date_1, %do i = 1 %to &num_spa-1; SPA_DATE_&i. , %end ; SPA_Date_&num_spa.) ;
%MEND MOST_RECENT_SPA ;
%MOST_RECENT_SPA;
run;
when i run it num_spa is not getting resolved. when i print it for checking purpose its like,
'CHECK NUM_SPA :' 4 with some leading space.
so i doubt NUM_SPA is created a character, when i try to compress the variable its not getting compressed. Can any one tell me wat could be the error in this code. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Have you tried
Code: |
CALL SYMPUT('NUM_SPA',COMPRESS(ROUND(NUM_VAL))); |
Also, see the difference in results when using
&NUM_SPA. and "&NUM_SPA."
Have a play with
Code: |
DATA _NULL_;
DEF = 'CHECK NUMBER 01 : '|| &NUM_SPA. ||' '|| "&NUM_SPA.";
PUT DEF;
PUT ' ';
PUT @01 'CHECK NUMBER 02 : '
+1 "&NUM_SPA."
+1 "&NUM_SPA.";
PUT ' ';
PUT @01 'CHECK NUMBER 03 : ' "&NUM_SPA.";
RUN; |
|
|
Back to top |
|
|
Subbulakshmi yogesh
New User
Joined: 28 Sep 2011 Posts: 8 Location: india
|
|
|
|
Thanks for you reply. I found the solution in a different way. my problem is
SPA_Date_&num_spa.) - the last date. when i give the mprint option, it gives me like (SPA_Date_ 4) with a space in it.
so i changed it as SPA_Date_&i. so it comes out of the do loop i value will be equal to num_spa value so it worked...
it pick up correctly for SPA_DATE_&i. |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hello,
Glad you got your issue resolved.
Just one other thing,
Quote: |
so i doubt NUM_SPA is created a character, |
All macro variables are character data types.
%let x= 10;
10 is treated as character.
Regards, |
|
Back to top |
|
|
|