<?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 proc fcmp in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/385993#M277170</link>
    <description>&lt;P&gt;Heey,&lt;/P&gt;&lt;P&gt;Is it possible using sas proc fcmp, to get a 2 &lt;SPAN&gt;dimensional&lt;/SPAN&gt; output like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = 1 to n;&lt;BR /&gt;   do j = 1 to p;
      mat[i,j]= i**j;
   end;
end;
return(mat);
endsub;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It can be done using array statements in a simple data step, but proc fcmp allows portable&amp;nbsp;fonctions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Aug 2017 13:23:12 GMT</pubDate>
    <dc:creator>DoumbiaS</dc:creator>
    <dc:date>2017-08-07T13:23:12Z</dc:date>
    <item>
      <title>proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/385993#M277170</link>
      <description>&lt;P&gt;Heey,&lt;/P&gt;&lt;P&gt;Is it possible using sas proc fcmp, to get a 2 &lt;SPAN&gt;dimensional&lt;/SPAN&gt; output like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = 1 to n;&lt;BR /&gt;   do j = 1 to p;
      mat[i,j]= i**j;
   end;
end;
return(mat);
endsub;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It can be done using array statements in a simple data step, but proc fcmp allows portable&amp;nbsp;fonctions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 13:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/385993#M277170</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-08-07T13:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/385997#M277171</link>
      <description>&lt;P&gt;User-defined functions can only return one value of type numeric or character. A return of a compound value (array or matrix) is not possible, AFAIK.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 13:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/385997#M277171</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-08-07T13:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/386008#M277172</link>
      <description>&lt;P&gt;Personally I would avoid fcmp as its just obfuscation to the nth degree. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;These are compiled functions and so can have any number of paramters, but only one return type and array is not a type but a collection. &amp;nbsp;From what you posted there, what would be the benefit of hiding that code? &amp;nbsp;It seems to be a simple do loop and array statement, so just use plain base SAS code, or if you really have to, put it in a macro.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 13:43:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/386008#M277172</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-07T13:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/386023#M277173</link>
      <description>&lt;P&gt;Yes. As&amp;nbsp;i said previously, it can be easily done using a data step with array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
array x{5};
do j= 1 to 3;&lt;BR /&gt;   do i= 1 to 5;
      x[i]= i**j;
   end;
   output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But such i want to handle it with many kind of data and return&amp;nbsp;an&amp;nbsp;output data...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 14:11:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/386023#M277173</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-08-07T14:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/386028#M277174</link>
      <description>&lt;P&gt;If you want to have code that changes depenging on parameters and data then you use Macro Language. &amp;nbsp;This is a code generation facililty which generates code based on these factors. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Compiled functions are there to do very specific small data manipulations, not to do large data manipulation tasks.&lt;/P&gt;
&lt;P&gt;Not sure what you mean by "&lt;SPAN&gt;but proc fcmp allows portable&amp;nbsp;fonctions"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SAS code is all text files, Macro is text files or compiled macro libraries just like fcmp. &amp;nbsp;For portability plain text files are ideal as they can be copied to any system and used in many ways. &amp;nbsp;FCMP and compiled macros hide the code and not as compatible across systems, protected ones even less so.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As you are creating general code, you would need to have more description, something like a functional design specifications which shows inputs/outputs etc. &amp;nbsp;From what you have posted code-wise, what do you want to be general, is it just the j/i variables if so:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;%macro Do_Calc (multiplier=,elements=);&lt;BR /&gt; data want;&lt;BR /&gt;   array x{&amp;amp;elements.};&lt;BR /&gt;   do j= 1 to &amp;amp;multiplier.;&lt;BR /&gt;     do i= 1 to &amp;amp;elements.;&lt;BR /&gt;       x[i]= i**j;&lt;BR /&gt;     end;&lt;BR /&gt;     output;&lt;BR /&gt;   end;&lt;BR /&gt; run;&lt;BR /&gt;%mend Do_Calc;&lt;BR /&gt;&lt;BR /&gt;%Do_Calc (multiplier=3,elements=5);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 14:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/386028#M277174</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-08-07T14:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/386064#M277176</link>
      <description>&lt;P&gt;You need to pass a two-dimensional _temporary_ array, n by p which at the time of compilation, will be be filled with missing values by default. Pass the array, n and p to Proc FCMP SUBROUTINE with OUTARG option to return the filled array. But there are painless ways of using FCMP to dynamically allocate arrays and write out the filled array as a data set. Your requirement is not sufficient to provide such easy ways.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one indirect way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib = work.cmpds.lib;
   subroutine fillmat(mat[*,*], n, p);
   outargs mat;
   do i = 1 to n;   
      do j = 1 to p;
         mat[i,j]= i**j;
      end;
   end;
endsub;
quit;

options cmplib = work.cmpds;
%let n = 4;&lt;BR /&gt;%let p = 3;
data _null_;

   array k[&amp;amp;n,&amp;amp;p] _temporary_;
   call fillmat(k,&amp;amp;n,&amp;amp;p);
   do i = 1 to &amp;amp;n;
      do j = 1 to &amp;amp;p;
         put k[i,j] =;
      end;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 15:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/386064#M277176</guid>
      <dc:creator>KachiM</dc:creator>
      <dc:date>2017-08-07T15:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: proc fcmp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/386219#M277177</link>
      <description>&lt;P&gt;Yes absolutly, i don't say enough... Thanks to everyone. &lt;SPAN class="short_text"&gt;&lt;SPAN&gt;Your ideas are brilliant&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 11:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-fcmp/m-p/386219#M277177</guid>
      <dc:creator>DoumbiaS</dc:creator>
      <dc:date>2017-08-08T11:57:10Z</dc:date>
    </item>
  </channel>
</rss>

