<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Trying to extract a data pair from a macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847081#M334903</link>
    <description>&lt;P&gt;We generally can't work from screen captures. Please, in the future, provide data as text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by you want to extract "ITERATIONS=10" from the macro variable? If you already know you want ITERATIONS=10, there's no need to extract it. Do you mean something else? Do you mean you want to extract the n-th data pair? Do you mean you want the data pair that begins with ITERATIONS?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Nov 2022 16:34:15 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-11-30T16:34:15Z</dc:date>
    <item>
      <title>Trying to extract a data pair from a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847078#M334901</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this macro variable:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jamal01_0-1669825541363.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77866i92745F970C5B8F80/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jamal01_0-1669825541363.png" alt="jamal01_0-1669825541363.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;and I am trying to extract "ITERATIONS=10", is there any way to do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Macro is from proc optmodel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you need any other info.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 16:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847078#M334901</guid>
      <dc:creator>jamal01</dc:creator>
      <dc:date>2022-11-30T16:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract a data pair from a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847081#M334903</link>
      <description>&lt;P&gt;We generally can't work from screen captures. Please, in the future, provide data as text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by you want to extract "ITERATIONS=10" from the macro variable? If you already know you want ITERATIONS=10, there's no need to extract it. Do you mean something else? Do you mean you want to extract the n-th data pair? Do you mean you want the data pair that begins with ITERATIONS?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 16:34:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847081#M334903</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-30T16:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract a data pair from a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847082#M334904</link>
      <description>&lt;P&gt;Sorry, here is the data:&amp;nbsp;&lt;/P&gt;&lt;P&gt;GLOBAL _OROPTMODEL_ STATUS=OK ALGORITHM=IP SOLUTION_STATUS=OPTIMAL OBJECTIVE=4482560894.6 PRIMAL_INFEASIBILITY=2.495295E-16&lt;BR /&gt;DUAL_INFEASIBILITY=9.21096E-19 BOUND_INFEASIBILITY=0 DUALITY_GAP=1.252394E-11 COMPLEMENTARITY=0 ITERATIONS=10 PRESOLVE_TIME=0.00&lt;BR /&gt;SOLUTION_TIME=0.02&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right, I can see that ITERATIONS=10 in the macro, but I was trying to write a small put statement and display something along the lines of "The number of iterations is 10".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 16:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847082#M334904</guid>
      <dc:creator>jamal01</dc:creator>
      <dc:date>2022-11-30T16:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract a data pair from a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847086#M334907</link>
      <description>&lt;P&gt;So, are you looking for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the N-th data pair&lt;/LI&gt;
&lt;LI&gt;a data pair that ends with 10&lt;/LI&gt;
&lt;LI&gt;a data pair that begins with ITERATIONS&lt;/LI&gt;
&lt;LI&gt;something else&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 30 Nov 2022 16:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847086#M334907</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-30T16:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract a data pair from a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847087#M334908</link>
      <description>&lt;P&gt;The pair that begins with ITERATIONS&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 16:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847087#M334908</guid>
      <dc:creator>jamal01</dc:creator>
      <dc:date>2022-11-30T16:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract a data pair from a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847091#M334911</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437114"&gt;@jamal01&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The pair that begins with ITERATIONS&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mvar=GLOBAL _OROPTMODEL_ STATUS=OK ALGORITHM=IP SOLUTION_STATUS=OPTIMAL OBJECTIVE=4482560894.6 PRIMAL_INFEASIBILITY=2.495295E-16 DUAL_INFEASIBILITY=9.21096E-19 BOUND_INFEASIBILITY=0 DUALITY_GAP=1.252394E-11 COMPLEMENTARITY=0 ITERATIONS=10 PRESOLVE_TIME=0.00 SOLUTION_TIME=0.02;

data _null_;
    where=find("&amp;amp;mvar",'ITERATIONS');
    want=scan(substr("&amp;amp;mvar",where),2,'= ');
    call symputx('want',want);
run;
%put &amp;amp;=want;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Nov 2022 16:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847091#M334911</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-30T16:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract a data pair from a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847114#M334917</link>
      <description>&lt;P&gt;This is what my log is looking like when I try to run it:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;1                                                          The SAS System                         18:06 Wednesday, November 30, 2022

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program';
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

4          %LET _CLIENTPROCESSFLOWNAME='Standalone Not In Project';
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

5          %LET _CLIENTPROJECTPATH='';
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

6          %LET _CLIENTPROJECTPATHHOST='';
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

7          %LET _CLIENTPROJECTNAME='';
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

8          %LET _SASPROGRAMFILE='';
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

9          %LET _SASPROGRAMFILEHOST='';
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=SVG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         %macro HTML5AccessibleGraphSupported;
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

15             %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) &amp;gt;= 0 %then ACCESSIBLE_GRAPH;
               _
               180
ERROR 180-322: Statement is not valid or it is used out of proper order.

16         %mend;
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

17         FILENAME EGHTML TEMP;
18         ODS HTML5(ID=EGHTML) FILE=EGHTML
2                                                          The SAS System                         18:06 Wednesday, November 30, 2022

19             OPTIONS(BITMAP_MODE='INLINE')
20             %HTML5AccessibleGraphSupported
               _
               22
               200
ERROR 22-322: Syntax error, expecting one of the following: ;, ACCESSIBLE_GRAPH, ANCHOR, ARCHIVE, ATTRIBUTES, BASE, BODY, 
              BOX_SIZING, CHARSET, CLOSE, CODE, CODEBASE, CONTENTS, CSS, CSSSTYLE, DOM, DPI, ENCODING, EVENT, FILE, FRAME, 
              GFOOTNOTE, GPATH, GTITLE, HEADTEXT, IMAGE_DPI, METATEXT, NEWFILE, NOACCESSIBLE_GRAPH, NOGFOOTNOTE, NOGTITLE, OPTIONS, 
              PACKAGE, PAGE, PARAMETERS, PATH, RECORD_SEPARATOR, SGE, STYLE, STYLESHEET, TEXT, TRANTAB.  

ERROR 200-322: The symbol is not recognized and will be ignored.

21             ENCODING='utf-8'
22             STYLE=HtmlBlue
23             NOGTITLE
24             NOGFOOTNOTE
25             GPATH=&amp;amp;sasworklocation
                     _
                     22
                     200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string.  
ERROR 200-322: The symbol is not recognized and will be ignored.
26         ;
27         
28         %let mvar=GLOBAL _OROPTMODEL_ STATUS=OK ALGORITHM=IP SOLUTION_STATUS=OPTIMAL OBJECTIVE=4482560894.6
           _
           180
28       ! PRIMAL_INFEASIBILITY=2.495295E-16 DUAL_INFEASIBILITY=9.21096E-19 BOUND_INFEASIBILITY=0 DUALITY_GAP=1.252394E-11
28       ! COMPLEMENTARITY=0 ITERATIONS=10 PRESOLVE_TIME=0.00 SOLUTION_TIME=0.02;
ERROR 180-322: Statement is not valid or it is used out of proper order.

29         
30         data _null_;
31             where=find("&amp;amp;mvar",'ITERATIONS');
32             want=scan(substr("&amp;amp;mvar",where),2,'= ');
33             call symputx('want',want);
34         run;
ERROR: Invalid second argument to function SUBSTR at line 32 column 15.
where=0 want=  _ERROR_=1 _N_=1
35         %put &amp;amp;=want;
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

36         
37         %LET _CLIENTTASKLABEL=;
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

38         %LET _CLIENTPROCESSFLOWNAME=;
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

39         %LET _CLIENTPROJECTPATH=;
           _
           180
3                                                          The SAS System                         18:06 Wednesday, November 30, 2022

ERROR 180-322: Statement is not valid or it is used out of proper order.

40         %LET _CLIENTPROJECTPATHHOST=;
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

41         %LET _CLIENTPROJECTNAME=;
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

42         %LET _SASPROGRAMFILE=;
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

43         %LET _SASPROGRAMFILEHOST=;
           _
           180
ERROR 180-322: Statement is not valid or it is used out of proper order.

44         
45         ;*';*";*/;quit;run;
46         ODS _ALL_ CLOSE;
47         
48         
49         QUIT; RUN;
50         &lt;/PRE&gt;&lt;P&gt;Any idea why this might be happening?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 18:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847114#M334917</guid>
      <dc:creator>jamal01</dc:creator>
      <dc:date>2022-11-30T18:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract a data pair from a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847116#M334918</link>
      <description>&lt;P&gt;Save your data sets, exit from SAS, re-launch SAS and try it again&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 18:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847116#M334918</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-30T18:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to extract a data pair from a macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847123#M334922</link>
      <description>&lt;P&gt;So if you have this string&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;GLOBAL _OROPTMODEL_ STATUS=OK ALGORITHM=IP SOLUTION_STATUS=OPTIMAL OBJECTIVE=4482560894.6 PRIMAL_INFEASIBILITY=2.495295E-16
DUAL_INFEASIBILITY=9.21096E-19 BOUND_INFEASIBILITY=0 DUALITY_GAP=1.252394E-11 COMPLEMENTARITY=0 ITERATIONS=10 PRESOLVE_TIME=0.00
SOLUTION_TIME=0.02&lt;/PRE&gt;
&lt;P&gt;It looks like is a series of name=value pairs delimited by spaces.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let string=
GLOBAL _OROPTMODEL_ STATUS=OK ALGORITHM=IP SOLUTION_STATUS=OPTIMAL OBJECTIVE=4482560894.6 PRIMAL_INFEASIBILITY=2.495295E-16
DUAL_INFEASIBILITY=9.21096E-19 BOUND_INFEASIBILITY=0 DUALITY_GAP=1.252394E-11 COMPLEMENTARITY=0 ITERATIONS=10 PRESOLVE_TIME=0.00
SOLUTION_TIME=0.02
;

data want;
  length index 8 name $32 value $32;
  length string $32767 ;
  string=symget('string');
  do index=1 to countw(string,' ');
     name = scan(scan(string,index,' '),1,'=');
     value = scan(scan(string,index,' '),2,'=');
     output;
  end;
  drop string;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Obs    index    name                    value

  1       1     GLOBAL
  2       2     _OROPTMODEL_
  3       3     STATUS                  OK
  4       4     ALGORITHM               IP
  5       5     SOLUTION_STATUS         OPTIMAL
  6       6     OBJECTIVE               4482560894.6
  7       7     PRIMAL_INFEASIBILITY    2.495295E-16
  8       8     DUAL_INFEASIBILITY      9.21096E-19
  9       9     BOUND_INFEASIBILITY     0
 10      10     DUALITY_GAP             1.252394E-11
 11      11     COMPLEMENTARITY         0
 12      12     ITERATIONS              10
 13      13     PRESOLVE_TIME           0.00
 14      14     SOLUTION_TIME           0.02
&lt;/PRE&gt;
&lt;P&gt;Looks like the beginning of the string does not follow the rules of the rest of the string.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 18:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-extract-a-data-pair-from-a-macro/m-p/847123#M334922</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-30T18:51:31Z</dc:date>
    </item>
  </channel>
</rss>

