<?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: Constructing Variables in a single step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386404#M92539</link>
    <description>&lt;P&gt;Are var3 var5 new varaibles to be added ?&lt;/P&gt;
&lt;P&gt;What is the logic rules to create those variables?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Aug 2017 20:13:12 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-08-08T20:13:12Z</dc:date>
    <item>
      <title>Constructing Variables in a single step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386396#M92533</link>
      <description>&lt;P&gt;Dear All:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;My data is as follows:&lt;/P&gt;&lt;P&gt;Name &amp;nbsp;&lt;/P&gt;&lt;P&gt;A&lt;/P&gt;&lt;P&gt;AA&lt;BR /&gt;AAA&lt;/P&gt;&lt;P&gt;AB&lt;/P&gt;&lt;P&gt;ABB&lt;/P&gt;&lt;P&gt;ABC&lt;/P&gt;&lt;P&gt;ACC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And so forth&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to contruct Variables such that the data set now looks like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name &amp;nbsp; &amp;nbsp; &amp;nbsp; Var3 &amp;nbsp; &amp;nbsp; &amp;nbsp;Var5&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;AA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;AAA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;AB &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; 1&lt;/P&gt;&lt;P&gt;ABB &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; 1&lt;/P&gt;&lt;P&gt;ABC&lt;/P&gt;&lt;P&gt;ACC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is possible to construct this data set with multiple steps. &amp;nbsp;But is there a shorter way.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Randy&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 20:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386396#M92533</guid>
      <dc:creator>RandyStan</dc:creator>
      <dc:date>2017-08-08T20:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Constructing Variables in a single step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386403#M92538</link>
      <description>&lt;P&gt;What are the rules for assigning those values to the other variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes if you have something like "I have to look at many records with this value for ID and then assign the (max, min, mean something else from the whole set) you may have to summarize the data and then remerge.&lt;/P&gt;
&lt;P&gt;But without some idea why a record gets var3 set to 1 and why set to missing anything would be a shot in the dark.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 20:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386403#M92538</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-08T20:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: Constructing Variables in a single step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386404#M92539</link>
      <description>&lt;P&gt;Are var3 var5 new varaibles to be added ?&lt;/P&gt;
&lt;P&gt;What is the logic rules to create those variables?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 20:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386404#M92539</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-08-08T20:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: Constructing Variables in a single step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386411#M92543</link>
      <description>&lt;P&gt;Please show us how you do it with multiple steps so that we can understand your logic.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 20:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386411#M92543</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-08-08T20:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Constructing Variables in a single step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386474#M92566</link>
      <description>&lt;P&gt;data group3 ; set names;&lt;/P&gt;&lt;P&gt;format Gr3 1.&lt;/P&gt;&lt;P&gt;gr3 = 1 ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data group3 ; set group3;&lt;/P&gt;&lt;P&gt;if _N_ gt 3 then delete;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data group5 ; set names;&lt;/P&gt;&lt;P&gt;format Gr5 1.&lt;/P&gt;&lt;P&gt;gr5 = 1 ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data group5 ; set group5;&lt;/P&gt;&lt;P&gt;if _N_ gt 5 then delete;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;merge names group3 group5;&lt;/P&gt;&lt;P&gt;by name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 04:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386474#M92566</guid>
      <dc:creator>RandyStan</dc:creator>
      <dc:date>2017-08-09T04:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Constructing Variables in a single step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386679#M92655</link>
      <description>&lt;P&gt;You mean like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set names;
   if _n_ le 3 then Gr3=1;
   if _n_ le 5 then Gr5=1;
run;
 
&lt;/PRE&gt;
&lt;P&gt;Note your example code was missing ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second data step to subset is redundant&lt;/P&gt;
&lt;PRE&gt;data group3 ; 
   set names;
   format Gr3 1.   ;
   gr3 = 1 ;
   if _N_ gt 3 then delete;

run;
&lt;/PRE&gt;
&lt;P&gt;The forum message windows will sometimes reformat text. It is best to post code and log info into a code box opened with the {i} icon in the menu row at the top of the window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2017 15:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Constructing-Variables-in-a-single-step/m-p/386679#M92655</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-09T15:43:49Z</dc:date>
    </item>
  </channel>
</rss>

