05-11-2018
DonnieJ
Obsidian | Level 7
Member since
04-11-2018
- 20 Posts
- 0 Likes Given
- 2 Solutions
- 1 Likes Received
-
Latest posts by DonnieJ
Subject Views Posted 7136 05-03-2018 12:19 PM 806 05-03-2018 12:10 PM 6455 05-02-2018 07:25 PM 6459 05-02-2018 07:09 PM 6490 05-02-2018 02:42 PM 6500 05-02-2018 02:34 PM 6524 05-02-2018 01:41 PM 6530 05-02-2018 01:37 PM 6538 05-02-2018 01:28 PM 6559 05-02-2018 01:04 PM -
Activity Feed for DonnieJ
- Got a Like for Re: PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A MACRO. 06-15-2021 04:32 PM
- Posted Re: PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A MACRO on SAS Programming. 05-03-2018 12:19 PM
- Posted Re: PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A MACRO on SAS Programming. 05-03-2018 12:10 PM
- Posted Re: PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A MACRO on SAS Programming. 05-02-2018 07:25 PM
- Posted Re: PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A MACRO on SAS Programming. 05-02-2018 07:09 PM
- Posted Re: PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A MACRO on SAS Programming. 05-02-2018 02:42 PM
- Posted Re: PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A MACRO on SAS Programming. 05-02-2018 02:34 PM
- Posted Re: PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A MACRO on SAS Programming. 05-02-2018 01:41 PM
- Posted Re: PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A MACRO on SAS Programming. 05-02-2018 01:37 PM
- Posted Re: PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A MACRO on SAS Programming. 05-02-2018 01:28 PM
- Posted PROC SQL SELECT INTO NOT ASSIGNING VALUE TO VARIABLE WHEN INSIDE A CALL EXECUTE INVOKED MACRO on SAS Programming. 05-02-2018 01:04 PM
- Posted Re: Global Variable not Resolving in Macro on SAS Programming. 04-19-2018 01:15 PM
- Posted Global Variable not Resolving in Macro on SAS Programming. 04-19-2018 12:52 PM
- Posted Global Variable not Resolving in Macro on SAS Programming. 04-19-2018 12:42 PM
- Posted Re: SAS - Write to CSV file using DO loop on SAS Programming. 04-12-2018 04:45 PM
- Posted Re: SAS - Write to CSV file using DO loop on SAS Programming. 04-12-2018 03:57 PM
- Posted Re: SAS - Write to CSV file using DO loop on SAS Programming. 04-12-2018 01:05 PM
- Posted Re: SAS - Write to CSV file using DO loop on SAS Programming. 04-11-2018 07:26 PM
- Posted Re: SAS - Write to CSV file using DO loop on SAS Programming. 04-11-2018 06:02 PM
- Posted SAS - Write to CSV file using DO loop on SAS Programming. 04-11-2018 05:24 PM
-
My Liked Posts
Subject Likes Posted 1 05-03-2018 12:19 PM
05-03-2018
12:19 PM
1 Like
Found this.... Now my code is working Usage Note 23134: Macro variables created with a CALL SYMPUT or SYMPUTX statement or an INTO clause do not resolve when invoked by the CALL EXECUTE routine If a CALL EXECUTE routine argument is invoked via a macro invocation or resolves to one, the macro code executes immediately. However, any SAS® statements (such as CALL SYMPUTX and INTO) that are produced by a CALL EXECUTE routine do not execute until after a step boundary has been passed. Because of this, the %NRSTR function has to be used in the CALL EXECUTE syntax. This enables you to reference the variables created by CALL SYMPUTX or INTO in the code generated by CALL EXECUTE. This workaround delays execution of the macro within the DATA step that contains the CALL EXECUTE. The use of %NRSTR in the following example masks the call to the %TEST macro when the argument to the CALL EXECUTE routine is evaluated. This causes the %TEST macro invocation to be pushed onto the input stack. Prior to using %NRSTR, all the non-macro statements generated were pushed to the input stack. %NRSTR delays the execution of the %TEST macro until after the RUN statement for the DATA step containing the CALL EXECUTE statement. Here is an example: /*sample data set*/
data a;
value='Hello';
run;
/*sample macro*/
%macro test(val);
data _null_;
call symput('num',200);
run;
%if &num eq 200 %then %do;
proc print data=&val;
run;
%end;
%mend;
/*this will fail*/
data _null_;
temp='a';
call execute('%test('||temp||')');
run;
/*work-around*/
data _null_;
temp='a';
call execute('%nrstr(%test('||temp||'))');
run; Starting with SAS® 9.3 M2, the new DOSUBL function can be used instead of CALL EXECUTE. Here is an example:
... View more
05-03-2018
12:10 PM
I have narrowed it down to my CALL EXECUTE causing the problem. If I call the macro normally my SELECT INTO will assign the variable. When my macro is called via CALL EXECUTE it does not assign the variable. I have a feeling this is an issue with my environment. I have notified SAS technical support.
... View more
05-02-2018
07:25 PM
I did, the SQL is valid and does return 1 number (no list). This works not using a macro.
... View more
05-02-2018
07:09 PM
I assigned a value of 0 using %let. The SELECT INTO did not update the value. It remained as 0. I contacted SAS Tech support because I re-created this problem in a much simpler way and it still does not assign the value inside a Macro. Used the same out not using a macro and it assigned the value. Keep in mind I'm not getting an error....the variable is "resolving", its just resolving as empty/null.
... View more
05-02-2018
02:42 PM
I did declare it as Global.
... View more
05-02-2018
02:34 PM
Global variable &FFYQTR is created way upstream in my program. It's resolving. I even tried this as a test... PROC SQL; SELECT 5 INTO :FCSTV FCSTV still will not resolve. Then I did this as a test... %LET FCSTV = 5 and it resolved. It looks like SELECT INTO goes out the window when being used INSIDE A MACRO
... View more
05-02-2018
01:41 PM
I know the interior DATA step wont update. I did that real quick to show the concept. The problem is the PRC SQL is not storing the value in the variable. Once I get this working I can complete my downstream code. Thanks!
... View more
05-02-2018
01:37 PM
I am in a mainframe environment. Sorry I did not mention that in the beginning. Thanks.
... View more
05-02-2018
01:28 PM
It is legal to have a subquery in the SELECT statement. Ex of what it is doing, SELECT (8500 - 8440) INTO :FCSTV
... View more
05-02-2018
01:04 PM
I am using a Macro as a means to run code dependent on a condition. My below code works when I am not using a Macro, but now that this code is being ran via a Macro my PROC SQL SELECT INTO is not storing the value inside the variable. Inside the macro I need to create a variable (FCSTV) and it will be passed downstream to be used in another macro. Below is the code.... DATA _NULL_;
CALL SYMPUT('FCST_Q', '1'); /* ENTER FCST QTR 0-NO | 1-YES */
%MACRO FCST_Q;
%GLOBAL FCSTV;
PROC SQL; /* STORE RUNDOWN & TOTAL FCST VARIANCE INTO VARIABLE */
SELECT (SELECT SALES
FROM RNDN
WHERE FYQTR = "&FFYQTR"
AND MTH = '1') - SUM(FCST)
INTO :FCSTV
FROM RDFCST;
%MACRO ADJUST_FCST;
%LOCAL i;
%LOCAL FVAR;
%LET FVAR = "&FCSTV";
%DO i = 1 %TO &FVAR;
DATA _NULL_; /* ADD REMAINING BALANCE TO FORECAST */
SET RDFCST;
IF _N_ = &i THEN DO;
FCST = FCST + 1;
END;
%END;
%MEND;
%ADJUST_FCST;
%MEND;
DATA _NULL_; /* TEST IF IN QTR FORECAST MODE */
IF "&FCST_Q" = '1' THEN CALL EXECUTE('%FCST_Q') The variable "FCSTV" is resoling to nothing. It is empty. Again, this code works if not bounded by the Macro %FCST_Q. Thanks for the help!
... View more
04-19-2018
12:52 PM
I am generating a Global variable using a SELECT :INTO and it was resolving before using a macro. Now I need to bound a large part of my code inside a macro and use a conditional CALL EXECUTE as a means to bypass or run my code. Now that I am generating this variable inside the macro, it is not resolving. Below is a simplified version of the code. Thanks for the help! %MACRO FCST_CHK1(IVINC);
%GLOBAL &IVINC; /* INCENTIVE FILE VIN COUNT */
PROC SQL; /* CREATE VIN COUNT FOR INCENTIVE FILE TEST */
SELECT COUNT(VIN17)
INTO :&IVINC
FROM INCV;
DATA _NULL_; /* TEST IF INCENTIVE FILE IS EMPTY */
IF &IVINC = 0 THEN DO;
FILE RETURNC;
PUT @01 'RETURN CODE 01: THE INCENTIVE FILE IS EMPTY';
ABORT RETURN 01;
END;
%MEND FCST_CHK1;
DATA _NULL_;
IF "&FCST_Y" = '0' THEN CALL EXECUTE('%FCST_CHK1(&IVINC)');
... View more
04-19-2018
12:42 PM
I have a global variable created by a SELECT :INTO and it was resolving when I was NOT using a macro. Now I need to bound a large part of my code inside a macro because I need to conditionally CALL EXECUTE this macro as a means to bypass or run the code. Below is a simplified version of what I am trying to do. The global variable &IVINC is not resolving. Thanks for the help! %MACRO FCST_CHK1(IVINC);
%GLOBAL &IVINC;
PROC SQL; SELECT COUNT(VIN17)
INTO :IVINC
FROM INCV;
DATA _NULL_; /* TEST IF INCENTIVE FILE IS EMPTY */
IF &IVINC = 0 THEN DO;
FILE RETURNC;
PUT @01 'RETURN CODE 01: THE INCENTIVE FILE IS EMPTY';
ABORT RETURN 01;
END;
%MEND(FCST_CHK1);
DATA _NULL_;
IF "&FCST_Y" = '0' THEN CALL EXECUTE('%FCST_CHK1(&IVINC)');
... View more
04-12-2018
04:45 PM
Got it working! Had to switch from "CATX" to "CATS" to solve the quote issue. Also, the DOLLAR10. was not displaying the whole figure due to extra spaces generated from the "VVALUEX" function.....so I had to add a "COMPRESS". Below is the working code. Thank you @Tom @ballardw @Astounding for your input and help, a total team effort! DATA _NULL_; /* DLR HIS */
FILE DLRHIS DELIMITER = ',';
SET DHISF;
C = ',';
IF _N_ = 1 THEN PUT "&DHISNAMES"; /*COLUMN HEADER */
LENGTH RECD $3000.;
DO i = 1 TO COUNTW("&DHISV");
VRBL = SCAN("&DHISV", i);
IF INDEX(VNAMEX(VRBL), 'PAY') > 0 THEN DO;
RECD = CATS(RECD,QUOTE(PUT(
INPUT(COMPRESS(VVALUEX(VRBL)),DOLLAR10.),DOLLAR10.))||C);
END;
IF INDEX(VNAMEX(VRBL), 'PAY') = 0 THEN DO;
RECD = CATS(RECD, COMPRESS(VVALUEX(VRBL))||C);
END;
END;
PUT RECD;
... View more
04-12-2018
03:57 PM
No errors.... looks like we're getting warmer. Below is the output. DATA _NULL_; /* DLR HIS */
FILE DLRHIS DELIMITER = ',';
SET DHISF;
C = ',';
Q = '"';
IF _N_ = 1 THEN PUT "&DHISNAMES"; /*COLUMN HEADER */
LENGTH RECD $3000.;
DO i = 1 TO COUNTW("&DHISV");
VRBL = SCAN("&DHISV", i);
IF INDEX(VNAMEX(VRBL), 'PAY') > 0 THEN DO;
RECD = CATX(' ',RECD,QUOTE(
PUT(INPUT(VVALUEX(VRBL),DOLLAR10.),DOLLAR10.))||C);
END;
IF INDEX(VNAMEX(VRBL), 'PAY') = 0 THEN DO;
RECD = CATX(' ', RECD, VVALUEX(VRBL)||C);
END;
END;
PUT RECD;
... View more