<?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: how to use proc iml to log transform negative values. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638357#M189831</link>
    <description>Oops, yes, I should indeed &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Wed, 08 Apr 2020 16:41:58 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2020-04-08T16:41:58Z</dc:date>
    <item>
      <title>how to use proc iml to log transform negative values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638198#M189772</link>
      <description>&lt;P&gt;Hi Folks:&lt;/P&gt;
&lt;P&gt;I've never used proc iml before and trying to use the approach suggested in the Wicklin's blog.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset with a variable with negative values which needs to be log transformed.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var;
cards;
-1
-2
;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And this step was suggested. Can you help me understand how I am supposed use the proc iml approach suggested so that variable 'var' with negative values in my 'have' dataset is translated and log transformed?&amp;nbsp;&lt;/P&gt;
&lt;PRE class="text"&gt;proc iml;
Y = {-3,1,2,.,5,10,100};    /* negative datum */
LY = log10(Y + 1 - min(Y)); /* translate, then transform */&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2011/04/27/log-transformations-how-to-handle-negative-data-values.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2011/04/27/log-transformations-how-to-handle-negative-data-values.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 23:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638198#M189772</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2020-04-07T23:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to use proc iml to log transform negative values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638207#M189779</link>
      <description>Y creates the vector there. You have a vector of -1, -2. You need to first load your data from a SAS data set into IML as a vector or matrix, since you only have one column a vector is fine. Then you can jump to the LY portion.&lt;BR /&gt;&lt;BR /&gt;This blog post has an example.&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2012/05/14/how-to-read-data-set-variables-into-sasiml-vectors.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2012/05/14/how-to-read-data-set-variables-into-sasiml-vectors.html&lt;/A&gt;</description>
      <pubDate>Wed, 08 Apr 2020 00:41:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638207#M189779</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-08T00:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to use proc iml to log transform negative values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638209#M189781</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, thanks a lot. Trying to understand the example. My actual data has about 1600 rows and 5 variables that all needed to be log transformed.</description>
      <pubDate>Wed, 08 Apr 2020 00:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638209#M189781</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2020-04-08T00:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to use proc iml to log transform negative values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638214#M189782</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Reeza, I get the following error. Also, after transforming the variable min_min_temp, then, how to integrate this vector back to my data set run my model on? I'm dumb founded.&amp;nbsp;Is it possible that you showcase on the 'have' data, please ?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
input date	min_min_temp max_max_temp;
cards;
20454	-5.9	12
20455	-2.7	16.8
20456	-2.3	16.6
20457	-3.2	15.2
20458	-6.1	11.1
20459	-7.8	9.9
20460	-7.6	8.5
20461	-8.9	7.5
20462	-6.2	9.4
20463	-3.9	10.9
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;5296  proc iml;
NOTE: IML Ready
5297  use weather1;
5298  read var {min_min_temp};
5299  Y = {min_min_temp};
5299!                        /* negative datum */
5300  Log_min_temp = log(Y + 1 - min(Y));
ERROR: (execution) Numeric argument should be character.

 operation : + at line 5300 column 22
 operands  : Y, *LIT1003

Y      1 row       1 col     (character, size 12)

 MIN_MIN_TEMP

*LIT1003      1 row       1 col     (numeric)

         1

 statement : ASSIGN at line 5300 column 1
5300!
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2020 01:06:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638214#M189782</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2020-04-08T01:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to use proc iml to log transform negative values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638344#M189827</link>
      <description>Why are you using IML then? Why not keep everything in a data step?</description>
      <pubDate>Wed, 08 Apr 2020 15:51:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638344#M189827</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-08T15:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to use proc iml to log transform negative values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638357#M189831</link>
      <description>Oops, yes, I should indeed &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 08 Apr 2020 16:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638357#M189831</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2020-04-08T16:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to use proc iml to log transform negative values.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638414#M189840</link>
      <description>&lt;P&gt;1. Run a proc means to get the minimum for each variable you want to analyze&lt;/P&gt;
&lt;P&gt;2. Merge that in to your data&lt;/P&gt;
&lt;P&gt;3. Set up two arrays, one for the raw data and one for the transformed data&lt;/P&gt;
&lt;P&gt;4. Set up an array for the means (temporary is also good, but not really needed)&lt;/P&gt;
&lt;P&gt;4. Loop through and do your transformations&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Adding summary statistics to a data set&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/add_average_value_to_dataset.sas" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/add_average_value_to_dataset.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a tutorial on using Arrays in SAS&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And an entirely different suggestion - look into the options in PROC STDIZE for data transformations but none seem close to what you want to do. Just something to keep in mind though.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 17:42:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-proc-iml-to-log-transform-negative-values/m-p/638414#M189840</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-08T17:42:22Z</dc:date>
    </item>
  </channel>
</rss>

