<?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: Output to a Macro variable within DS2 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Output-to-a-Macro-variable-within-DS2/m-p/692834#M211148</link>
    <description>&lt;P&gt;No, there is no way.&lt;/P&gt;
&lt;P&gt;DS2 opens up a lot of coding avenues and shuts down some others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Functional Trickery can be attempted but will eventually fail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One extreme is write a custom function in FCMP that acts as an adapter for the FCMP function RUN_MACRO that is invoked via a DS2 FCMP package.&amp;nbsp; However, at DS2 program runtime the FCMP package execution domain will be sandboxed as well and the custom function will fail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example of failed trickery (Cannot find a library containing subroutine RUN_MACRO)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;options nosource;

%global hackysack;

%macro mvassign;
  %let hackysack = &amp;amp;value;
%mend;

* interface function to run_macro (which has its own foibles);
proc fcmp outlib=work.hacks.interface;
  function mvassign (value $);
    return (run_macro('mvassign',value));
  endsub;
run;

data have;
  word = "Hello";
run;


* test user defined function 'mvassign' in DATA Step execution domain;
* hint: this works
%let hackysack=;
data _null_;
  set have;
  rc = mvassign(word);
run;
%put &amp;amp;=hackysack;


* test user defined function 'mvassign' in Proc DS2 step DATA program;
%let hackysack=;
proc ds2;
  package hackspkg / overwrite=yes language='fcmp' table='work.hacks';
  run;
  data _null_;
    declare package hackspkg hackro();

    method run();
      set have;
    end;
    method term();
      declare double rc;
      put 'NOTE:' word= ' &amp;lt;------------- in ds2 data program term section';
      rc = hackro.mvassign(word);
    end;
  enddata;
  run;
quit;
%put &amp;amp;=hackysack;

----- LOG -----
NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           0.48 seconds
      cpu time            0.17 seconds


HACKYSACK='Hello'   (FOIBLED result from run_macro interface function)

NOTE: Created package hackspkg in data set work.hackspkg.
NOTE: Execution succeeded. No rows affected.
NOTE: word=Hello  &amp;lt;------------- in ds2 data program term section
ERROR: Cannot find a library containing subroutine RUN_MACRO.
ERROR: Function RUN_MACRO not found.
ERROR: Line 3392: FCMP function failed with internal error.
ERROR: General error

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE DS2 used (Total process time):
      real time           0.10 seconds
      cpu time            0.09 seconds

HACKYSACK=

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There may be some eventual hackery that does work, but it would be far outside the norm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Oct 2020 12:27:46 GMT</pubDate>
    <dc:creator>RichardDeVen</dc:creator>
    <dc:date>2020-10-20T12:27:46Z</dc:date>
    <item>
      <title>Output to a Macro variable within DS2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-a-Macro-variable-within-DS2/m-p/692726#M211090</link>
      <description>&lt;P&gt;Since there are no CALL statements, is there a way to output to a Macro variable from within a DS2 block?&lt;/P&gt;
&lt;P&gt;Something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  word = "Hello";
run;

proc ds2;
  data _null_;
    method run();
      set have;
    end;
    method term();
      put word;
      call symput('word',word);
    end;
  enddata;
  run;
quit;

%put &amp;amp;word;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Oct 2020 01:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-a-Macro-variable-within-DS2/m-p/692726#M211090</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-10-20T01:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Output to a Macro variable within DS2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-a-Macro-variable-within-DS2/m-p/692834#M211148</link>
      <description>&lt;P&gt;No, there is no way.&lt;/P&gt;
&lt;P&gt;DS2 opens up a lot of coding avenues and shuts down some others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Functional Trickery can be attempted but will eventually fail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One extreme is write a custom function in FCMP that acts as an adapter for the FCMP function RUN_MACRO that is invoked via a DS2 FCMP package.&amp;nbsp; However, at DS2 program runtime the FCMP package execution domain will be sandboxed as well and the custom function will fail.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example of failed trickery (Cannot find a library containing subroutine RUN_MACRO)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;options nosource;

%global hackysack;

%macro mvassign;
  %let hackysack = &amp;amp;value;
%mend;

* interface function to run_macro (which has its own foibles);
proc fcmp outlib=work.hacks.interface;
  function mvassign (value $);
    return (run_macro('mvassign',value));
  endsub;
run;

data have;
  word = "Hello";
run;


* test user defined function 'mvassign' in DATA Step execution domain;
* hint: this works
%let hackysack=;
data _null_;
  set have;
  rc = mvassign(word);
run;
%put &amp;amp;=hackysack;


* test user defined function 'mvassign' in Proc DS2 step DATA program;
%let hackysack=;
proc ds2;
  package hackspkg / overwrite=yes language='fcmp' table='work.hacks';
  run;
  data _null_;
    declare package hackspkg hackro();

    method run();
      set have;
    end;
    method term();
      declare double rc;
      put 'NOTE:' word= ' &amp;lt;------------- in ds2 data program term section';
      rc = hackro.mvassign(word);
    end;
  enddata;
  run;
quit;
%put &amp;amp;=hackysack;

----- LOG -----
NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: DATA statement used (Total process time):
      real time           0.48 seconds
      cpu time            0.17 seconds


HACKYSACK='Hello'   (FOIBLED result from run_macro interface function)

NOTE: Created package hackspkg in data set work.hackspkg.
NOTE: Execution succeeded. No rows affected.
NOTE: word=Hello  &amp;lt;------------- in ds2 data program term section
ERROR: Cannot find a library containing subroutine RUN_MACRO.
ERROR: Function RUN_MACRO not found.
ERROR: Line 3392: FCMP function failed with internal error.
ERROR: General error

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE DS2 used (Total process time):
      real time           0.10 seconds
      cpu time            0.09 seconds

HACKYSACK=

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There may be some eventual hackery that does work, but it would be far outside the norm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 12:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-a-Macro-variable-within-DS2/m-p/692834#M211148</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-10-20T12:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Output to a Macro variable within DS2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-to-a-Macro-variable-within-DS2/m-p/692935#M211193</link>
      <description>&lt;P&gt;I was afraid of that.&amp;nbsp; I am finding DS2 can't be used to write processes that do not know the variable names in advance.&amp;nbsp; I might post another question that get more directly at that issue.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2020 15:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-to-a-Macro-variable-within-DS2/m-p/692935#M211193</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-10-20T15:43:55Z</dc:date>
    </item>
  </channel>
</rss>

