<?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 dates in PROC SQL outside the SELECT statement ? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289492#M59657</link>
    <description>&lt;P&gt;Your problem lies in this:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"I have 2 datasets with a lot of variables"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It is never a good idea - from a programming point of view - to work with lots of variables. &amp;nbsp;To write proper SQL then you should specify every variable you require in the output dataset - this is the point of the select statement. &amp;nbsp;The fact that you have lots of variables is a structural problem - and it seems to be endemic in SAS - where you then have problems coding because of the structure. &amp;nbsp;Trust me, this will not be the first problem you encounter with such a data structure. &amp;nbsp;Consider re-structuring into a form which is beneficial to programming - nothing stops you tranposing the data before reporting it.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Aug 2016 11:47:42 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-08-04T11:47:42Z</dc:date>
    <item>
      <title>How to format dates in PROC SQL outside the SELECT statement ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289476#M59645</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 datasets with a lot of variables, that I need to join.&lt;/P&gt;&lt;P&gt;I'm looking for a way to format just one date column without having to reference it in the SELECT statement,.&lt;/P&gt;&lt;P&gt;My reason for this is that if I reference that specific column I cannot use &lt;STRONG&gt;dataset1.*&lt;/STRONG&gt; syntax and would be obliged to write down all of the variables.&lt;/P&gt;&lt;P&gt;On the same note, does anyone know of a way in proc sql to insert a column from a second table in a certain position in the first table?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 10:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289476#M59645</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2016-08-04T10:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to format dates in PROC SQL outside the SELECT statement ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289477#M59646</link>
      <description>&lt;P&gt;I do not know, if it solves your problem but I use proc sql feedback option to list all columns used in proc sql.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ex&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql feedback;&lt;/P&gt;&lt;P&gt;select a.*&lt;/P&gt;&lt;P&gt;from table1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now check the log and get list of all column and replace it with *&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 10:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289477#M59646</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-08-04T10:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to format dates in PROC SQL outside the SELECT statement ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289480#M59649</link>
      <description>That's really nice and I'll definitely use it in the future, but with my current data this code becomes quite large and unattractive.</description>
      <pubDate>Thu, 04 Aug 2016 10:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289480#M59649</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2016-08-04T10:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to format dates in PROC SQL outside the SELECT statement ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289487#M59653</link>
      <description>&lt;P&gt;The variable sequence in SQL is determined by the order in the select statement. By using *, you are bound to the original order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you only need to change the attribute of one variable, determine the name, and then use PROC DATASETS, MODIFY with ATTRIB to change the format for that variable.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 10:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289487#M59653</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-04T10:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to format dates in PROC SQL outside the SELECT statement ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289492#M59657</link>
      <description>&lt;P&gt;Your problem lies in this:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"I have 2 datasets with a lot of variables"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It is never a good idea - from a programming point of view - to work with lots of variables. &amp;nbsp;To write proper SQL then you should specify every variable you require in the output dataset - this is the point of the select statement. &amp;nbsp;The fact that you have lots of variables is a structural problem - and it seems to be endemic in SAS - where you then have problems coding because of the structure. &amp;nbsp;Trust me, this will not be the first problem you encounter with such a data structure. &amp;nbsp;Consider re-structuring into a form which is beneficial to programming - nothing stops you tranposing the data before reporting it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 11:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289492#M59657</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-04T11:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to format dates in PROC SQL outside the SELECT statement ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289498#M59658</link>
      <description>&lt;P&gt;This worked perfectly. Thank you !&lt;/P&gt;&lt;P&gt;For those interested my code looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets;
	modify dataset1;
	attrib Datevar format=monyy.;
run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Aug 2016 12:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289498#M59658</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2016-08-04T12:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to format dates in PROC SQL outside the SELECT statement ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289499#M59659</link>
      <description>Thank you for your response, but I've already done the programming with just the variables I'm interested in. Now I'm just looking to change the output presentation for a client in order to look smooth and clean.</description>
      <pubDate>Thu, 04 Aug 2016 12:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289499#M59659</guid>
      <dc:creator>Elle</dc:creator>
      <dc:date>2016-08-04T12:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to format dates in PROC SQL outside the SELECT statement ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289506#M59660</link>
      <description>&lt;P&gt;Well, you will either have to write a correctly ordered list in SQL by hand, or use an "empty format" statement in a data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
format
  var3
  var1
  var2
  var4
  ...
;
set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if only some variables need to be ordered, one could conceive of a method to automatically create the list from a dataset extracted from sashelp.vcolumn.&lt;/P&gt;
&lt;P&gt;- put the known variable names in a macro variable, in wanted order&lt;/P&gt;
&lt;P&gt;- in a data step, read all dataset variables and add only those that do not already appear in the macrovar (thus making the list complete)&lt;/P&gt;
&lt;P&gt;- create the select list or the "empty format" from the macro variable&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 12:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289506#M59660</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-04T12:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to format dates in PROC SQL outside the SELECT statement ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289564#M59666</link>
      <description>&lt;P&gt;If you're using SAS Enterprise Guide, you might like this custom task:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/sasdummy/2015/10/28/copy-sas-variable-names-to-the-clipboard-in-sas-enterprise-guide/" target="_self"&gt;Copy SAS variable names to the clipboard in SAS Enterprise Guide&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It provides a shortcut for adding a list of variable names -- in various formats -- into your program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4438iC3B9128E4E8457E1/image-size/large?v=v2&amp;amp;px=-1" border="0" alt="threecopytasks.png" title="threecopytasks.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2016 15:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289564#M59666</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-08-04T15:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to format dates in PROC SQL outside the SELECT statement ?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289739#M59676</link>
      <description>&lt;PRE&gt;
proc sql;
 create table class as
  select * from sashelp.class;
  
 alter table class 
  modify age format=date9.;
quit; 

&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Aug 2016 07:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-format-dates-in-PROC-SQL-outside-the-SELECT-statement/m-p/289739#M59676</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-08-05T07:27:34Z</dc:date>
    </item>
  </channel>
</rss>

