<?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: creating a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-a-variable/m-p/471714#M120858</link>
    <description>&lt;P&gt;For a very large number of analysis or display purposes what you propose doing may not be needed at all. If the "date" is an actual SAS date value and not character then a change of the display format for a procedure may be all that is needed. See this example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   informat date mmddyy10. ;
   format date mmddyy10.;
   input date value;
datalines;
01/01/2018  123
01/23/2018  24
01/31/2018  456
02/02/2018  333
02/05/2018  6
;
run;

proc means data=example;
   class date;
   var value;
run;

proc means data=example;
   class date;
   var value;
   format date monyy5.;
run;&lt;/PRE&gt;
&lt;P&gt;No additional variable was needed to get different groups for analysis, just a change of format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Almost all of the analysis, grahping and reporting procedures like Report and Tabulate will honor the format for creating groups.&lt;/P&gt;
&lt;P&gt;Also Proc Format will allow you create specific date, time or datetime appearances if you can't find a SAS supplied format that appears exactly as you want.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jun 2018 14:42:51 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-06-20T14:42:51Z</dc:date>
    <item>
      <title>creating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-variable/m-p/471619#M120815</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following data-set&amp;nbsp; with first three variables, and I want to create another variable &lt;STRONG&gt;month&lt;/STRONG&gt; such that it represents the month and year of the date variable. Any suggestions on how to create it?&l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/2000&lt;/TD&gt;&lt;TD&gt;Feb-00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2/2/2000&lt;/TD&gt;&lt;TD&gt;Feb-00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;….&lt;/TD&gt;&lt;TD&gt;Feb-00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;…..&lt;/TD&gt;&lt;TD&gt;Feb-00&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2/29/2000&lt;/TD&gt;&lt;TD&gt;Feb-00&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 20 Jun 2018 07:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-variable/m-p/471619#M120815</guid>
      <dc:creator>Amalik</dc:creator>
      <dc:date>2018-06-20T07:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: creating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-variable/m-p/471623#M120816</link>
      <description>&lt;P&gt;Not sure how mabny ways there is to type this:&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;Post test data in the form of a datastep!!!&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;So now lets start the guessing, is date an actual numeric date value?&amp;nbsp; If so then:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  month=put(date,monyy.);
run;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#n1anshj9oarqccn15eulfy9mnszl.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#n1anshj9oarqccn15eulfy9mnszl.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 07:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-variable/m-p/471623#M120816</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-20T07:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: creating a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-a-variable/m-p/471714#M120858</link>
      <description>&lt;P&gt;For a very large number of analysis or display purposes what you propose doing may not be needed at all. If the "date" is an actual SAS date value and not character then a change of the display format for a procedure may be all that is needed. See this example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   informat date mmddyy10. ;
   format date mmddyy10.;
   input date value;
datalines;
01/01/2018  123
01/23/2018  24
01/31/2018  456
02/02/2018  333
02/05/2018  6
;
run;

proc means data=example;
   class date;
   var value;
run;

proc means data=example;
   class date;
   var value;
   format date monyy5.;
run;&lt;/PRE&gt;
&lt;P&gt;No additional variable was needed to get different groups for analysis, just a change of format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Almost all of the analysis, grahping and reporting procedures like Report and Tabulate will honor the format for creating groups.&lt;/P&gt;
&lt;P&gt;Also Proc Format will allow you create specific date, time or datetime appearances if you can't find a SAS supplied format that appears exactly as you want.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 14:42:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-a-variable/m-p/471714#M120858</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-20T14:42:51Z</dc:date>
    </item>
  </channel>
</rss>

