<?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: Using arrays for log and sqrt functions in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251652#M56729</link>
    <description>&lt;P&gt;You will need two arrays for each transformation.&amp;nbsp; One is for the input, one for the output.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set speed;&lt;/P&gt;
&lt;P&gt;array in {3} y1-y3;&lt;/P&gt;
&lt;P&gt;array out {3} sy1-sy3;&lt;/P&gt;
&lt;P&gt;do _i_=1 to 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; out{_i_} = sqrt(in{_i_});&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you consider what this statement means:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sqrt = (1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is saying assign a value to the variable named SQRT.&amp;nbsp; There is no function being applied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Feb 2016 22:01:50 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-02-22T22:01:50Z</dc:date>
    <item>
      <title>Using arrays for log and sqrt functions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251635#M56721</link>
      <description>&lt;P&gt;Trying to use arrays for log and square root functions. &amp;nbsp;First, how do I get each individual log and square root function, for example, it is giving me the log for all of x1-x5, however I just want it for each subset of data, for example, x1 is 1 and 11, I want the log of just that. &amp;nbsp;In addition, how do I get the x1-x5 and the y1-y3 on the same output, right now, (using seperate statements), I can get the log of x1-x5 (not individually) and if I run a seperate statement I can get the square root of sy1-sy3, not inidivdually....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data speed;&lt;BR /&gt;input X1-X5 Y1-Y3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 2 3 4 5 6 7 8&lt;BR /&gt;11 22 33 44 55 66 77 88&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data speed2 (drop=x1-x5 i);&lt;BR /&gt;set work.speed;&lt;BR /&gt;array num {5} lx1-lx5;&lt;BR /&gt;do i= 1 to 5;&lt;BR /&gt;log = (i);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;data speed2 (drop=y1-y3 i);&lt;/P&gt;&lt;P&gt;array let {3} sy1-sy3;&lt;BR /&gt;do i=1 to 3;&lt;BR /&gt;sqrt&amp;nbsp;= (i);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 21:26:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251635#M56721</guid>
      <dc:creator>zjhansen30</dc:creator>
      <dc:date>2016-02-22T21:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays for log and sqrt functions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251636#M56722</link>
      <description>&lt;P&gt;Can you please post some sample output data, what are you expecting?&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 21:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251636#M56722</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-22T21:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays for log and sqrt functions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251637#M56723</link>
      <description>&lt;P&gt;It is giving me the log of all 5 combined for x1-x5, I wanted it for each column, for example x1 is 1 and 11, then x2 is 2 and 22, etc...&lt;/P&gt;&lt;P&gt;X1 &amp;nbsp; X2 &amp;nbsp;X3 X4 X5 LX1 LX2 LX3 LX4 LX5 Log&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp;4 &amp;nbsp; 5 &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; 5&lt;BR /&gt;11 &amp;nbsp; 22 &amp;nbsp; 33 &amp;nbsp;44 55 &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 21:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251637#M56723</guid>
      <dc:creator>zjhansen30</dc:creator>
      <dc:date>2016-02-22T21:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays for log and sqrt functions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251640#M56724</link>
      <description>&lt;P&gt;You're making a couple of mistakes, in how you're using the functions. Also, you need variables to store the results. I'm assuming new variables, but you could reuse the same variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data speed;
input X1-X5 Y1-Y3;
datalines;
1 2 3 4 5 6 7 8
11 22 33 44 55 66 77 88
;

data want;
set speed;
array x(5);
array y(3);
array lx(5);
array ly(3);
array sqrt_x(5);
array sqrt_y(3);

do i=1 to dim(x);
	lx(i)=log(x(i));
	sqrt_x(i)=sqrt(x(i));
end;

do i=1 to dim(y);
	ly(i)=log(y(i));
	sqrt_y(i)=sqrt(y(i));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2016 21:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251640#M56724</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-22T21:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays for log and sqrt functions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251642#M56726</link>
      <description>Thank you so much. I was getting confused and that was over my head, but I used this&lt;BR /&gt;&lt;BR /&gt;data speed2 (drop=y1-y3 x1-x5 i);&lt;BR /&gt;set speed;&lt;BR /&gt;array x(5);&lt;BR /&gt;array y(3);&lt;BR /&gt;array lx(5);&lt;BR /&gt;array sy(3);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;do i=1 to 5;&lt;BR /&gt;lx(i)=log(x(i));&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;do i=1 to 3;&lt;BR /&gt;&lt;BR /&gt;sy(i)=sqrt(y(i));&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;run;</description>
      <pubDate>Mon, 22 Feb 2016 21:48:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251642#M56726</guid>
      <dc:creator>zjhansen30</dc:creator>
      <dc:date>2016-02-22T21:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays for log and sqrt functions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251643#M56727</link>
      <description>&lt;P&gt;You have to read the existing variables into an arry and then access the arrays and call the LOG and SQRT functions.&amp;nbsp; I've put all results into a single data set, but you can create two data seta sets if you prefer:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data speed2 (drop=x1-x5 y1-y3 i);
set work.speed;
array logX {5} lx1-lx5;     /* for new variables */
array X[5] x1-x5;           /* existing vars */
array sqrtY {3} sy1-sy3;    /* for new vars */
array Y[3] y1-y3;           /* existing vars */

do i= 1 to 5;
   logX[i] = log(x[i]);
end;
do i=1 to 3;
   sqrtY[i] = sqrt(y[i]);
end;
run;

proc print; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2016 21:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251643#M56727</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-02-22T21:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using arrays for log and sqrt functions</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251652#M56729</link>
      <description>&lt;P&gt;You will need two arrays for each transformation.&amp;nbsp; One is for the input, one for the output.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set speed;&lt;/P&gt;
&lt;P&gt;array in {3} y1-y3;&lt;/P&gt;
&lt;P&gt;array out {3} sy1-sy3;&lt;/P&gt;
&lt;P&gt;do _i_=1 to 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; out{_i_} = sqrt(in{_i_});&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you consider what this statement means:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sqrt = (1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is saying assign a value to the variable named SQRT.&amp;nbsp; There is no function being applied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 22:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-arrays-for-log-and-sqrt-functions/m-p/251652#M56729</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-02-22T22:01:50Z</dc:date>
    </item>
  </channel>
</rss>

