<?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 How to use format/informat to reorder a variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-format-informat-to-reorder-a-variable/m-p/689929#M24703</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have imported a CSV file, and run proc tabulate. However, my variables 'season' and 'day' are in alphabetical order, and I want them to be inlogical order. Therefore, I have used CARDS to create 2 new datasets- 'seasons', which is the month in correct order, and 'orderday' which is the day in correct order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, how do I use these two datasets to create a proc tabulate like the one described above? I want to do this by using FORMAT and INFORMAT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Oct 2020 11:10:42 GMT</pubDate>
    <dc:creator>jeffgreen</dc:creator>
    <dc:date>2020-10-08T11:10:42Z</dc:date>
    <item>
      <title>How to use format/informat to reorder a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-format-informat-to-reorder-a-variable/m-p/689929#M24703</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have imported a CSV file, and run proc tabulate. However, my variables 'season' and 'day' are in alphabetical order, and I want them to be inlogical order. Therefore, I have used CARDS to create 2 new datasets- 'seasons', which is the month in correct order, and 'orderday' which is the day in correct order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, how do I use these two datasets to create a proc tabulate like the one described above? I want to do this by using FORMAT and INFORMAT.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 11:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-format-informat-to-reorder-a-variable/m-p/689929#M24703</guid>
      <dc:creator>jeffgreen</dc:creator>
      <dc:date>2020-10-08T11:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use format/informat to reorder a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-format-informat-to-reorder-a-variable/m-p/689937#M24705</link>
      <description>&lt;P&gt;It would be easier if you had SAS dates as values, as&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;the values sort correctly by themselves&lt;/LI&gt;
&lt;LI&gt;you can use SAS-supplied formats for display&lt;/LI&gt;
&lt;LI&gt;you can easily create custom formats (e.g. a MMDD format that omits the year) for such values&lt;/LI&gt;
&lt;LI&gt;SAS procedures will use the formatted values, but can be instructed to keep the underlying order&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Without that, I suggest you create a format for the pure month numbers:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value mymonth
  1 = 'January'
  2 = 'February'
  3 = 'March'
/* and so on */
;
run;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After applying this format to your month variable, you can then use ORDER=UNFORMATTED in the CLASS statement of PROC TABULATE.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 11:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-format-informat-to-reorder-a-variable/m-p/689937#M24705</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-08T11:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to use format/informat to reorder a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-format-informat-to-reorder-a-variable/m-p/690002#M24707</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/343927"&gt;@jeffgreen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have imported a CSV file, and run proc tabulate. However, my variables 'season' and 'day' are in alphabetical order, and I want them to be inlogical order. Therefore, I have used CARDS to create 2 new datasets- 'seasons', which is the month in correct order, and 'orderday' which is the day in correct order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My question is, how do I use these two datasets to create a proc tabulate like the one described above? I want to do this by using FORMAT and INFORMAT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since we would have to see exact values to make any sort of useable informat then provide the data step code with the cards statement. Copy the code and paste into a code box opened on the forum with the &amp;lt;/&amp;gt; icon to prevent the forum message windows from reformatting text which can cause such code not to execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most consistent would be to read the values into a numeric variable so the order is easier to maintain with an Order=data in proc tabulate and then a format to display the values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Better might actually be to provide some example of the CSV file and the code you use to read that. Reading the CSV would be best time to use an informat to avoid creating additional variables that may be needed after these values that don't sort as desired.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 14:20:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-format-informat-to-reorder-a-variable/m-p/690002#M24707</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-10-08T14:20:20Z</dc:date>
    </item>
  </channel>
</rss>

