<?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 formatting nlstrmon. as character in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/formatting-nlstrmon-as-character/m-p/628021#M20621</link>
    <description>&lt;P&gt;Hello! As part of a create table select proc sql, I am utilizing nlstrmon. to return the month name from a datetime20. formatted field.&amp;nbsp; The output data shows the month name, however it is formatted as a numeric field 8 bytes in length.&amp;nbsp; When exported to Excel, the month name converts back to the corresponding month number.&amp;nbsp; Any suggestions for changing the formatting to character?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;			
			
	create table work.XXXX as		
	select 	month(table.field) format=nlstrmon. as MONTH&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Feb 2020 19:11:20 GMT</pubDate>
    <dc:creator>hnb_matt_d</dc:creator>
    <dc:date>2020-02-27T19:11:20Z</dc:date>
    <item>
      <title>formatting nlstrmon. as character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/formatting-nlstrmon-as-character/m-p/628021#M20621</link>
      <description>&lt;P&gt;Hello! As part of a create table select proc sql, I am utilizing nlstrmon. to return the month name from a datetime20. formatted field.&amp;nbsp; The output data shows the month name, however it is formatted as a numeric field 8 bytes in length.&amp;nbsp; When exported to Excel, the month name converts back to the corresponding month number.&amp;nbsp; Any suggestions for changing the formatting to character?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;			
			
	create table work.XXXX as		
	select 	month(table.field) format=nlstrmon. as MONTH&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Feb 2020 19:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/formatting-nlstrmon-as-character/m-p/628021#M20621</guid>
      <dc:creator>hnb_matt_d</dc:creator>
      <dc:date>2020-02-27T19:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: formatting nlstrmon. as character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/formatting-nlstrmon-as-character/m-p/628023#M20623</link>
      <description>&lt;P&gt;You using confusing terminology. A format is an attribute of a variable.&amp;nbsp; SAS has just two variable &lt;STRONG&gt;TYPE&lt;/STRONG&gt;s, either floating point numbers or a fixed length character strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like you are currently converting a date value (number of days since 1960) into a month value (integer between 1 and 12) by using the MONTH() function. Then attached a format that show that number as a month name.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sounds like you would prefer to create a character variable instead.&amp;nbsp; Use the PUT() function to get the result of display the value using a given format specification.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;put(month(table.field),nlstrmon.) as MONTH&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A format is instructions for converting values into text.&amp;nbsp; You can attach them to a variable (as in your original code) and SAS will use them as the default way to display the values.&amp;nbsp; But if you use PROC EXPORT or XLSX libname engine to convert your data into an EXCEL it will copy the value, not how it is displayed.&amp;nbsp; For some key formats, like date, time and datetime, SAS tries to convert the value to a matching value in Excel and attach an appropriate display format to the cell.&amp;nbsp; But it does not know how to map every possible format into an Excel equivalent.&amp;nbsp; Is there even an Excel equivalent that displays 1 as January?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 19:20:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/formatting-nlstrmon-as-character/m-p/628023#M20623</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-27T19:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: formatting nlstrmon. as character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/formatting-nlstrmon-as-character/m-p/628024#M20624</link>
      <description>Try the MONNAME format instead? You can use the date with that function directly. &lt;BR /&gt;&lt;BR /&gt;put(table.field, monname.) as Month</description>
      <pubDate>Thu, 27 Feb 2020 19:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/formatting-nlstrmon-as-character/m-p/628024#M20624</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-27T19:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: formatting nlstrmon. as character</title>
      <link>https://communities.sas.com/t5/New-SAS-User/formatting-nlstrmon-as-character/m-p/628033#M20627</link>
      <description>&lt;P&gt;Thank you, Tom and Reeza, for replying!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both produced output, but not proper results.&amp;nbsp; Building on what Reeza suggested, I've done this and it produced desired results and exported to Excel as desired:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select 	
	put(datepart(table.field), monname.) as MONTH&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you both so much for the quick replies!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Matt D&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 20:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/formatting-nlstrmon-as-character/m-p/628033#M20627</guid>
      <dc:creator>hnb_matt_d</dc:creator>
      <dc:date>2020-02-27T20:15:32Z</dc:date>
    </item>
  </channel>
</rss>

