<?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: How to format a variable in proc sql without specify its name in select statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212788#M52546</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd use proc datasets afterwards to apply the format instead of fiddling with the SQL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming you're too lazy to type out all the variables you can use &lt;/P&gt;&lt;P&gt;PROC SQL feedback;&lt;/P&gt;&lt;P&gt;rest of code;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;check the log and it will list all the variables and you can modify the ones you want. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're using * to select all because you expect variables to change in the future this method won't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Mar 2015 18:56:39 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-03-30T18:56:39Z</dc:date>
    <item>
      <title>How to format a variable in proc sql without specify its name in select statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212785#M52543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello everyone,&lt;/P&gt;&lt;P&gt;Does anyone know how I can format a variable in proc sql without specify its name in select statement?(I know I can do it if i specify its name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql; select a $18,b,c from ......,but i want use * to choose all variables here)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the problem code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table need as&lt;/P&gt;&lt;P&gt;select *&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;format a =$18&lt;/STRONG&gt;&lt;/SPAN&gt;. from one&lt;/P&gt;&lt;P&gt;group by b,c&lt;/P&gt;&lt;P&gt;order by a;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 15:54:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212785#M52543</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2015-03-30T15:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to format a variable in proc sql without specify its name in select statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212786#M52544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If it is only one variable you might be able to use an ALTER TABLE statement on the created output in a separate bit of code.&lt;BR /&gt;after created table need:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;alter table need modify a format=$18.;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 16:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212786#M52544</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-03-30T16:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to format a variable in proc sql without specify its name in select statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212787#M52545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can code: &lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;create table need as&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;select zz.*,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; af = zz.a&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; text-decoration: underline;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;format = $18&lt;/STRONG&gt;&lt;/SPAN&gt;. &lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;from one zz&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;group by b,c&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;order by af;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on your situation, you will have to delete a then rename af if your program is looking for a later on.&amp;nbsp; You should also need to trim zz.a if a's length is longer than 18 characters.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 18:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212787#M52545</guid>
      <dc:creator>jwillis</dc:creator>
      <dc:date>2015-03-30T18:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to format a variable in proc sql without specify its name in select statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212788#M52546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd use proc datasets afterwards to apply the format instead of fiddling with the SQL. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming you're too lazy to type out all the variables you can use &lt;/P&gt;&lt;P&gt;PROC SQL feedback;&lt;/P&gt;&lt;P&gt;rest of code;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;check the log and it will list all the variables and you can modify the ones you want. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're using * to select all because you expect variables to change in the future this method won't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 18:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212788#M52546</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-03-30T18:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to format a variable in proc sql without specify its name in select statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212789#M52547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; background-color: #ffffff;"&gt;thanks,some revise:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; background-color: #ffffff;"&gt;proc sql;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; background-color: #ffffff;"&gt;create table need as&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; background-color: #ffffff;"&gt;select zz.*,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="text-decoration: underline;"&gt;zz.a as af&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; text-decoration: underline;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;format = $18&lt;/STRONG&gt;&lt;/SPAN&gt;. &lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; background-color: #ffffff;"&gt;from one zz&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; background-color: #ffffff;"&gt;group by b,c&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; background-color: #ffffff;"&gt;order by af;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue',Helvetica,Arial,'Lucida Grande',sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Apr 2015 17:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212789#M52547</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2015-04-04T17:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to format a variable in proc sql without specify its name in select statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212790#M52548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;value fmt&lt;/P&gt;&lt;P&gt;1-12='young'&lt;/P&gt;&lt;P&gt;other='old';run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table need as&lt;/P&gt;&lt;P&gt;select zz.*,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zz.age as af&amp;nbsp; format = fmt.&lt;/P&gt;&lt;P&gt;from sashelp.class as zz;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc datasets nolist;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; modify need;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rename age=age2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format age2 fmt.;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Apr 2015 17:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-a-variable-in-proc-sql-without-specify-its-name-in/m-p/212790#M52548</guid>
      <dc:creator>GeorgeSAS</dc:creator>
      <dc:date>2015-04-04T17:30:59Z</dc:date>
    </item>
  </channel>
</rss>

