<?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: arbitrary variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/663927#M78950</link>
    <description>Hi,&lt;BR /&gt;Its definitely written by someone else.. I got this code from sascrunch training - data analysis section.- what i meant is that i didnt understand the concept of using 'i' . seen the situation in other training sections also. Could you please elaborate on this.&lt;BR /&gt;many thanks</description>
    <pubDate>Mon, 22 Jun 2020 07:29:03 GMT</pubDate>
    <dc:creator>jjoy4891</dc:creator>
    <dc:date>2020-06-22T07:29:03Z</dc:date>
    <item>
      <title>arbitrary variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/663911#M78948</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am very new to SAS , and am stuck with some basic concept like using arbitrary variable for merging data sets &amp;gt; Could some one please explain the logic for the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Num2;&lt;BR /&gt;Set Num;&lt;BR /&gt;i = 1; *Create an arbitrary variable for merging purpose;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;proc means data=num2 noprint;&lt;BR /&gt;Var Rnumber;&lt;BR /&gt;By i;&lt;BR /&gt;Output out=stat mean=mean std=std;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Data Zscore;&lt;BR /&gt;Merge Num2 Stat;&lt;BR /&gt;By i;&lt;BR /&gt;Zscore = (Rnumber - Mean)/std;&lt;BR /&gt;Run;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 04:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/663911#M78948</guid>
      <dc:creator>jjoy4891</dc:creator>
      <dc:date>2020-06-22T04:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: arbitrary variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/663925#M78949</link>
      <description>&lt;P&gt;Apparently, this program was written by someone who is just slightly more advanced than you are.&amp;nbsp; The real problem is to get the MEAN and STD appended to each observation, to support Z score calculations.&amp;nbsp; This can be done in several ways, none of which involve creating an arbitrary variable for merging.&amp;nbsp; Here is the way that most closely resembles the existing program.&amp;nbsp; Begin with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=num noprint;
   var Rnumber;
   output out=stat mean=mean std=std;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;At this point, you might want to examine the results since you could use some familiarity with what the program does.&amp;nbsp; Then continue with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data zscore;
   if _n_=1 then set stat (keep=mean std);
   set num;
   zscore = (Rnumber - mean) / std;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are several other ways to accomplish this task (SQL, macro language, even a SAS procedure that standardizes variables).&amp;nbsp; But this is the way that is closest to your existing program.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 07:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/663925#M78949</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-06-22T07:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: arbitrary variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/663927#M78950</link>
      <description>Hi,&lt;BR /&gt;Its definitely written by someone else.. I got this code from sascrunch training - data analysis section.- what i meant is that i didnt understand the concept of using 'i' . seen the situation in other training sections also. Could you please elaborate on this.&lt;BR /&gt;many thanks</description>
      <pubDate>Mon, 22 Jun 2020 07:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/663927#M78950</guid>
      <dc:creator>jjoy4891</dc:creator>
      <dc:date>2020-06-22T07:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: arbitrary variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/663985#M78953</link>
      <description>&lt;P&gt;The concept of the entire program is this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to understand (and possibly already understand) how MERGE works in SAS.&amp;nbsp; MERGE requires a common variable (or variables) used to match on, to combine the variables from two data sets onto the same observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These two data sets ... the original data, plus the results from PROC MEANS ... do not have a common variable.&amp;nbsp; So the program makes one up.&amp;nbsp; It calls the variable "i" and gives it an arbitrary value so it will match all the time.&amp;nbsp; It doesn't matter what value is assigned to "i" (whether it is "1" or "abc") as long as it matches between the two data sets.&amp;nbsp; That allows a MERGE step to take place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally you would sort your data sets first, before using MERGE.&amp;nbsp; In this case, there is no need to sort, since the variable takes on only one value.&amp;nbsp; For the purposes of MERGE, the data sets are already sorted.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jun 2020 13:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/663985#M78953</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-06-22T13:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: arbitrary variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/664072#M78954</link>
      <description>Thank you so much for the explanation.</description>
      <pubDate>Mon, 22 Jun 2020 21:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/arbitrary-variable/m-p/664072#M78954</guid>
      <dc:creator>jjoy4891</dc:creator>
      <dc:date>2020-06-22T21:19:42Z</dc:date>
    </item>
  </channel>
</rss>

