<?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 Assigning data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15826#M2829</link>
    <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to deal with repetitve data in PROC FORMAT?  &lt;BR /&gt;
&lt;BR /&gt;
For example:&lt;BR /&gt;
month a b a1 a2 a3 a4&lt;BR /&gt;
10 1 0 2 4 3 5&lt;BR /&gt;
10 2 1 3 1 5 4&lt;BR /&gt;
10 3 1 2 4 5 1&lt;BR /&gt;
10 4 0 2 3 1 5&lt;BR /&gt;
10 5 0 1 4 3 2&lt;BR /&gt;
11 1 1 2 5 4 3&lt;BR /&gt;
11 2 0 1 5 3 4&lt;BR /&gt;
11 3 1 2 4 5 1&lt;BR /&gt;
11 4 0 1 5 3 2&lt;BR /&gt;
11 5 1 4 3 2 1&lt;BR /&gt;
........&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
Similar to my previous post, I need the value of "b", that is associated with a particular "a" value per each month, to replace any a1-a4 value (when a1-a4 equal a) for that month.  I got an error saying that values overlap when I ran proc format.  Thank you.</description>
    <pubDate>Thu, 09 Apr 2009 23:38:00 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-04-09T23:38:00Z</dc:date>
    <item>
      <title>Assigning data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15822#M2825</link>
      <description>Hello Everyone:&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset in this format.&lt;BR /&gt;
&lt;BR /&gt;
a b a1 a2 a3 a4&lt;BR /&gt;
1 0 2 4 6 8&lt;BR /&gt;
2 1 3 1 5 7&lt;BR /&gt;
3 1 2 4 6 7&lt;BR /&gt;
4 0 2 3 1 5&lt;BR /&gt;
5 0 1 4 3 2&lt;BR /&gt;
6 1 2 5 7 9&lt;BR /&gt;
7 0 8 5 3 2&lt;BR /&gt;
8 1 3 6 7 2&lt;BR /&gt;
9 0 1 5 3 2&lt;BR /&gt;
10 1 7 9 2 1&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
Please note that for any observation (row), a is not equal to a1, a2, a3, and a4.  Basically what I want do is to assign 0/1 to the variables a1-a4 based on variable 'a''s association with b.  So for example, when a = 3, b = 1.  Now, I want a value of 1 to be assigned to variables a1-a4 whose value anywhere in the dataset is equal to 3.  When  a1 = 7 (10th observation), then the value of 7 needs to be replaced by 0 since when a = 7 b = 0, and so forth.  Any suggestion will be greatly appreciated.  Thank you.</description>
      <pubDate>Tue, 07 Apr 2009 04:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15822#M2825</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-07T04:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15823#M2826</link>
      <description>For convenience in coding within a DATA step, you can setup an array defined for the range of variables a1-a4 and have a SAS code construct like shown below to assign any of the array variable based on "a" value:&lt;BR /&gt;
&lt;BR /&gt;
DO X=1 to DIM(your_array);  &lt;BR /&gt;
  &lt;YOUR_ASSIGNMENT_CODE&gt;&lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
For the other instances where you are assigning values, simply code an IF &lt;CONDITION&gt; THEN &lt;ASSIGNMENT logic=""&gt;; within the same DATA step.&lt;BR /&gt;
&lt;BR /&gt;
Here is a link to the SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  where you can find SAS-hosted documentation on the ARRAY and other SAS Language references.  Also, there are technical conference papers and supplemental SAS examples on the site for general use and reference, using the SEARCH facility.&lt;BR /&gt;
&lt;BR /&gt;
Reading Raw Data:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001112330.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a001112330.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
ARRAY processing references:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a002299816.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a002299816.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000739610.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/61722/HTML/default/a000739610.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/ASSIGNMENT&gt;&lt;/CONDITION&gt;&lt;/YOUR_ASSIGNMENT_CODE&gt;</description>
      <pubDate>Tue, 07 Apr 2009 07:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15823#M2826</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-04-07T07:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15824#M2827</link>
      <description>You can use a format to achieve this goal.  If you want to actually replace the values of A1-A4 then use an array and [pre]input(put(array[index],a2b.),f8.)[/pre] or similar.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data a;&lt;BR /&gt;
   input &lt;BR /&gt;
a b a1 a2 a3 a4;&lt;BR /&gt;
   cards;&lt;BR /&gt;
 1 0 2 4 6 8&lt;BR /&gt;
 2 1 3 1 5 7&lt;BR /&gt;
 3 1 2 4 6 7&lt;BR /&gt;
 4 0 2 3 1 5&lt;BR /&gt;
 5 0 1 4 3 2&lt;BR /&gt;
 6 1 2 5 7 9&lt;BR /&gt;
 7 0 8 5 3 2&lt;BR /&gt;
 8 1 3 6 7 2&lt;BR /&gt;
 9 0 1 5 3 2&lt;BR /&gt;
10 1 7 9 2 1&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
data cntl;&lt;BR /&gt;
   retain fmtname 'a2b' type 'N';&lt;BR /&gt;
   set a;&lt;BR /&gt;
   start = a;&lt;BR /&gt;
   label = b;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc format cntlin=cntl;&lt;BR /&gt;
   select a2b;   &lt;BR /&gt;
   run;&lt;BR /&gt;
proc print data=a;&lt;BR /&gt;
   format a1-a4 a2b.;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 07 Apr 2009 11:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15824#M2827</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-04-07T11:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15825#M2828</link>
      <description>Scott, I tried to assign numbers just using arrays but it never really worked even after spending considerable time.  But the proc format seems to work pretty good.  Thanks to you both for great suggestions!!</description>
      <pubDate>Wed, 08 Apr 2009 00:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15825#M2828</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-08T00:47:54Z</dc:date>
    </item>
    <item>
      <title>Assigning data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15826#M2829</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to deal with repetitve data in PROC FORMAT?  &lt;BR /&gt;
&lt;BR /&gt;
For example:&lt;BR /&gt;
month a b a1 a2 a3 a4&lt;BR /&gt;
10 1 0 2 4 3 5&lt;BR /&gt;
10 2 1 3 1 5 4&lt;BR /&gt;
10 3 1 2 4 5 1&lt;BR /&gt;
10 4 0 2 3 1 5&lt;BR /&gt;
10 5 0 1 4 3 2&lt;BR /&gt;
11 1 1 2 5 4 3&lt;BR /&gt;
11 2 0 1 5 3 4&lt;BR /&gt;
11 3 1 2 4 5 1&lt;BR /&gt;
11 4 0 1 5 3 2&lt;BR /&gt;
11 5 1 4 3 2 1&lt;BR /&gt;
........&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
Similar to my previous post, I need the value of "b", that is associated with a particular "a" value per each month, to replace any a1-a4 value (when a1-a4 equal a) for that month.  I got an error saying that values overlap when I ran proc format.  Thank you.</description>
      <pubDate>Thu, 09 Apr 2009 23:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Assigning-data/m-p/15826#M2829</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-09T23:38:00Z</dc:date>
    </item>
  </channel>
</rss>

