<?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 divide observations by a fixed one in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-divide-observations-by-a-fixed-one/m-p/28804#M5358</link>
    <description>Hi Olivier,&lt;BR /&gt;
&lt;BR /&gt;
Many thanks for your reply.&lt;BR /&gt;
I am not sure to well understand. I have to create new variables for each week_i of my Z(last or first) row? &lt;BR /&gt;
Here is the macro:&lt;BR /&gt;
&lt;BR /&gt;
%Macro DUMMY_PERF_HEBDO (table=) ;&lt;BR /&gt;
     data &amp;amp;table.2 (drop=monthly_perf_week_1-monthly_perf_week_500);&lt;BR /&gt;
          set &amp;amp;table ;&lt;BR /&gt;
		  array monthly_perf_week_[&amp;amp;_N_week] monthly_perf_week_1-monthly_perf_week_500;&lt;BR /&gt;
		  array dummy_week_[500] dummy_week_1-dummy_week_500;&lt;BR /&gt;
		  retain monthly_perf_week_1-monthly_perf_week_500 dummy_week_1-dummy_week_500 ;&lt;BR /&gt;
							&lt;BR /&gt;
		  /*ATTENTION aux 1 premières données week_n*/&lt;BR /&gt;
          do _i=5 to 500;	&lt;BR /&gt;
          											&lt;BR /&gt;
		  If (monthly_perf_week_(_i)=0 or monthly_perf_week_(_i)=.) then dummy_week_(_i)=.;&lt;BR /&gt;
		  ELSE if BETA =0 then dummy_week_(_i)=.;&lt;BR /&gt;
          Else dummy_week_(_i)=(monthly_perf_week_(_i)-BETA*(monthly_perf_week_(_i)/* THE LAST OR FIRST ROW  */ ); &lt;BR /&gt;
     	  End;&lt;BR /&gt;
   	 run;&lt;BR /&gt;
%Mend ;&lt;BR /&gt;
&lt;BR /&gt;
Thanks,</description>
    <pubDate>Wed, 02 Jul 2008 09:54:10 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-07-02T09:54:10Z</dc:date>
    <item>
      <title>how to divide observations by a fixed one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-divide-observations-by-a-fixed-one/m-p/28802#M5356</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have a problem with a matrice. Could you help?&lt;BR /&gt;
 I have a table that looks like: &lt;BR /&gt;
&lt;BR /&gt;
name year coefficient week_1 week_2 ...week_n&lt;BR /&gt;
A       Y_1&lt;BR /&gt;
A       Y_2&lt;BR /&gt;
A       Y_3&lt;BR /&gt;
B       Y_1&lt;BR /&gt;
B       Y_2&lt;BR /&gt;
B       Y_3&lt;BR /&gt;
C       Y_1&lt;BR /&gt;
C       Y_2&lt;BR /&gt;
C       Y_3&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
Z         .&lt;BR /&gt;
&lt;BR /&gt;
I would like to divide all week_i values of Names (A B C) by &lt;BR /&gt;
                                  week_i values of Name (Z) * coefficient(A B C).&lt;BR /&gt;
&lt;BR /&gt;
Do you have an idea? &lt;BR /&gt;
Can I use the lag function in a do-loop to keep the Z row in reference? because I try and it doesn't work...&lt;BR /&gt;
&lt;BR /&gt;
Many thanks,&lt;BR /&gt;
&lt;BR /&gt;
anais</description>
      <pubDate>Wed, 02 Jul 2008 08:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-divide-observations-by-a-fixed-one/m-p/28802#M5356</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-07-02T08:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: how to divide observations by a fixed one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-divide-observations-by-a-fixed-one/m-p/28803#M5357</link>
      <description>Hi Anaïs.&lt;BR /&gt;
What you have to do is sort your data set to have the Z observation on the very first observation. Then read the dataset with a DATA step, and&lt;BR /&gt;
[pre]&lt;BR /&gt;
RETAIN Zvalue ;&lt;BR /&gt;
IF _N_=1 THEN Zvalue = value ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
The RETAIN instruction will ensure that the value is remembered for any further observation read.&lt;BR /&gt;
If there are several values to remember, declare every variable in a single RETAIN, and create them in the IF _N_=1 statement. You can use ARRAYs to simplify syntax, working on week_1, week_2, etc.&lt;BR /&gt;
Regards.&lt;BR /&gt;
Olivier</description>
      <pubDate>Wed, 02 Jul 2008 09:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-divide-observations-by-a-fixed-one/m-p/28803#M5357</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-07-02T09:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: how to divide observations by a fixed one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-divide-observations-by-a-fixed-one/m-p/28804#M5358</link>
      <description>Hi Olivier,&lt;BR /&gt;
&lt;BR /&gt;
Many thanks for your reply.&lt;BR /&gt;
I am not sure to well understand. I have to create new variables for each week_i of my Z(last or first) row? &lt;BR /&gt;
Here is the macro:&lt;BR /&gt;
&lt;BR /&gt;
%Macro DUMMY_PERF_HEBDO (table=) ;&lt;BR /&gt;
     data &amp;amp;table.2 (drop=monthly_perf_week_1-monthly_perf_week_500);&lt;BR /&gt;
          set &amp;amp;table ;&lt;BR /&gt;
		  array monthly_perf_week_[&amp;amp;_N_week] monthly_perf_week_1-monthly_perf_week_500;&lt;BR /&gt;
		  array dummy_week_[500] dummy_week_1-dummy_week_500;&lt;BR /&gt;
		  retain monthly_perf_week_1-monthly_perf_week_500 dummy_week_1-dummy_week_500 ;&lt;BR /&gt;
							&lt;BR /&gt;
		  /*ATTENTION aux 1 premières données week_n*/&lt;BR /&gt;
          do _i=5 to 500;	&lt;BR /&gt;
          											&lt;BR /&gt;
		  If (monthly_perf_week_(_i)=0 or monthly_perf_week_(_i)=.) then dummy_week_(_i)=.;&lt;BR /&gt;
		  ELSE if BETA =0 then dummy_week_(_i)=.;&lt;BR /&gt;
          Else dummy_week_(_i)=(monthly_perf_week_(_i)-BETA*(monthly_perf_week_(_i)/* THE LAST OR FIRST ROW  */ ); &lt;BR /&gt;
     	  End;&lt;BR /&gt;
   	 run;&lt;BR /&gt;
%Mend ;&lt;BR /&gt;
&lt;BR /&gt;
Thanks,</description>
      <pubDate>Wed, 02 Jul 2008 09:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-divide-observations-by-a-fixed-one/m-p/28804#M5358</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-07-02T09:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to divide observations by a fixed one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-divide-observations-by-a-fixed-one/m-p/28805#M5359</link>
      <description>Hi olivier, &lt;BR /&gt;
&lt;BR /&gt;
I've added new variables and it works very well!&lt;BR /&gt;
&lt;BR /&gt;
The "RETAIN Zvalue ;IF _N_=1 THEN Zvalue = value ;" codes is repeating the value in each cell of the column.&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot,&lt;BR /&gt;
&lt;BR /&gt;
anais</description>
      <pubDate>Wed, 02 Jul 2008 11:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-divide-observations-by-a-fixed-one/m-p/28805#M5359</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-07-02T11:17:02Z</dc:date>
    </item>
  </channel>
</rss>

