<?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: Format and Informat Statements With Empty Dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887556#M350650</link>
    <description>&lt;P&gt;Are you asking what rules PROC SQL uses to decide which FORMAT (or INFORMAT) to attach to a variable that is sourced from multiple datasets?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know for a DATA STEP it will attach the first (non empty) format that it sees.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run some tests with PROC SQL and find out for yourself.&amp;nbsp; Make sure to include some variables that have no format and/or no informat attached at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your description seems to say that for PROC SQL is uses the LAST one it sees.&amp;nbsp; Or perhaps it picks the FIRST but that it processes the different contributing datasets in a bottom up (or LIFO, last in first out) order.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Aug 2023 20:23:48 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-08-02T20:23:48Z</dc:date>
    <item>
      <title>Format and Informat Statements With Empty Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887538#M350645</link>
      <description>&lt;P&gt;When specifying a format and informat statement on columns in an EMPTY dataset, I'm finding the format and informat don't stick. Is there a way around this issue? I can understand if it's working as designed but am wondering if there is a way to set format and informat on an empty dataset column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More specifically, the empty dataset is in a "create view" proc sql UNION statement, snippet below. The empty dummy placeholders in the first union select, I believe, is causing the format/informat not to stick? The second union select DOES have data in those columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE VIEW AS&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;'-' as field1,&lt;BR /&gt;'-' as field2,&lt;BR /&gt;0 as field3,&lt;BR /&gt;&lt;BR /&gt;FROM TABLE1&lt;BR /&gt;union&lt;BR /&gt;SELECT&amp;nbsp;&lt;/P&gt;&lt;P&gt;field1,&lt;/P&gt;&lt;P&gt;field2,&lt;/P&gt;&lt;P&gt;field3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FROM TABLE2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;--&amp;gt; RESULT: even though field1, field2, and field3 are defined with specific FORMAT and INFORMAT settings in union select #2, those FORMAT and INFORMAT settings don't carry over to the final view.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 19:59:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887538#M350645</guid>
      <dc:creator>shl007</dc:creator>
      <dc:date>2023-08-02T19:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Format and Informat Statements With Empty Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887541#M350646</link>
      <description>&lt;P&gt;Define "empty dataset".&lt;/P&gt;
&lt;P&gt;I don't see any attempt to create a data set. The code creates a VIEW (which is not named) which is quite different in some respects. It in effect reruns the code when the View is USED. So if you do not apply a changed format or informat in the steps that create a View then you get the properties at the time the code next executes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What code did you attempt to apply format and informat? I don't see any attempt in your code. &lt;/P&gt;
&lt;P&gt;Did the format or informat type agree with the variable type?&lt;/P&gt;
&lt;P&gt;Show the log with the code and any notes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both the the data steps below create data sets with no observations and successfully assign formats and informats so it is not a limitation of a data set not allow setting formats or other properties for variables.&lt;/P&gt;
&lt;PRE&gt;data junk;
  set sashelp.class (obs=0);
  format age F32.12;
  informat weight f5.;
run;

data newjunk;
   input x y z;
   format x F18. y Date9. ;
   informat z mmddyy10.;
datalines;
;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 20:14:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887541#M350646</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-02T20:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: Format and Informat Statements With Empty Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887542#M350647</link>
      <description>&lt;P&gt;For me format and informat stick !&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.have;
input testcol $;
format testcol $50.;
attrib testcol informat=$50.; 
datalines;
run;

proc contents; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 20:03:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887542#M350647</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-08-02T20:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Format and Informat Statements With Empty Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887549#M350648</link>
      <description>I think I solved the above issue by ensuring my 2nd union select was FIRST so that the view respected the informats and formats from the 2nd select!</description>
      <pubDate>Wed, 02 Aug 2023 20:07:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887549#M350648</guid>
      <dc:creator>shl007</dc:creator>
      <dc:date>2023-08-02T20:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: Format and Informat Statements With Empty Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887556#M350650</link>
      <description>&lt;P&gt;Are you asking what rules PROC SQL uses to decide which FORMAT (or INFORMAT) to attach to a variable that is sourced from multiple datasets?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know for a DATA STEP it will attach the first (non empty) format that it sees.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run some tests with PROC SQL and find out for yourself.&amp;nbsp; Make sure to include some variables that have no format and/or no informat attached at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your description seems to say that for PROC SQL is uses the LAST one it sees.&amp;nbsp; Or perhaps it picks the FIRST but that it processes the different contributing datasets in a bottom up (or LIFO, last in first out) order.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 20:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-and-Informat-Statements-With-Empty-Dataset/m-p/887556#M350650</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-08-02T20:23:48Z</dc:date>
    </item>
  </channel>
</rss>

