<?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: Reading out using PUT in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-out-using-PUT-in-SAS/m-p/567873#M159752</link>
    <description>&lt;P&gt;The discrepancy between the numbers of variables in datasets TEST and TC_LEVEL_JUNE01 indicates that the PUT statement uses 870-516=354 variable names that are not contained in&amp;nbsp;TC_LEVEL_JUNE01, i.e., the PUT statement doesn't match the dataset, which is alarming. Even worse, if exactly 516 variable names are listed in the PUT statement, 354 variables from TC_LEVEL_JUNE01 will not be written to JUNE012.csv, only missing values instead. Normally, TEST would be an identical copy of TC_LEVEL_JUNE01 (and therefore typically omitted by using a &lt;FONT face="courier new,courier"&gt;data _null_&lt;/FONT&gt;&amp;nbsp;statement).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Watch out for log messages like&lt;/P&gt;
&lt;PRE&gt;NOTE: Variable NEWVAR is uninitialized.&lt;/PRE&gt;
&lt;P&gt;to identify the mismatching variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, consider using the DSD option (which is useful if a character value happens to contain the delimiter) if you want to create a CSV file and not a text file with fixed field widths and without delimiters (as is suggested by your PUT statement).&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jun 2019 11:15:39 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2019-06-21T11:15:39Z</dc:date>
    <item>
      <title>Reading out using PUT in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-out-using-PUT-in-SAS/m-p/567862#M159748</link>
      <description>&lt;DIV class="votecell post-layout--left"&gt;&lt;DIV class="js-voting-container grid fd-column ai-stretch gs4 fc-black-200"&gt;I usually use PROC EXPORT to read out data from SAS to a csv or .dat file.&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="postcell post-layout--right"&gt;&lt;DIV class="post-text"&gt;&lt;P&gt;I've been given a readout that uses PUT statement but I can't find an example of how to use this that works for me.&lt;/P&gt;&lt;P&gt;What I have at the minute is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA TEST;
SET TC_LEVEL_JUNE01;
FILE "C:\users\JUNE012.csv"
	LRECL = 7353;
	PUT
	@5 TENANCY_REFERENCE_NUMBER $20.
	@25 TENANT_ID $20.
	@45 RECORD_TYPE 2.
	@47 EVENT_TYPE 2.
	@49 NODE_TYPE $8.
	@57 CLOSURE_TYPE $1.
	@58 CLOSED_DATE 8.
	@66 EXTRACT_TYPE 2.
	@68 OPEN_DATE 8.
	@76 DATE_LAST_ACTIVE 8.
	@84 NUMBER_TENANTS 2.
	@86 NUMBER_OCCUPANTS 2.
	@88 RENT_TYPE $20.
	@108 TENANCY_START_DATE 8.
	@116 TENANCY_END_DATE 8.
....... more outputs until
	@7310 SPAREDATE_5 8.;  
RUN;&lt;/PRE&gt;&lt;P&gt;This creates a dataset called TEST with 870 fields but the dataset&amp;nbsp;TC_LEVEL_JUNE01 has 516 fields (which is correct). I'm not sure why it's creating more fields in the&amp;nbsp; TEST dataset and the read out is not correct either.&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Jun 2019 09:48:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-out-using-PUT-in-SAS/m-p/567862#M159748</guid>
      <dc:creator>manonlyn</dc:creator>
      <dc:date>2019-06-21T09:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reading out using PUT in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-out-using-PUT-in-SAS/m-p/567869#M159750</link>
      <description>&lt;P&gt;csv is the Acronym for &lt;STRONG&gt;C&lt;/STRONG&gt;omma &lt;STRONG&gt;S&lt;/STRONG&gt;eparated &lt;STRONG&gt;V&lt;/STRONG&gt;olume, but is sometimes interpreted as Character Separated Volume (eg by Excel, which uses semicolons instead of commas). Either way, a csv has to be a delimited file without fixed columns, so set a proper delimiter and discard the positions and formats in the put statement, but set formats as needed in a separate format statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set tc_level_june01;
file"C:\users\JUNE012.csv" lrecl=7353 dlm=',';
format
  RECORD_TYPE 2.
  EVENT_TYPE 2.
;
put
  TENANCY_REFERENCE_NUMBER
  TENANT_ID
  RECORD_TYPE
  EVENT_TYPE

..........

;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jun 2019 10:32:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-out-using-PUT-in-SAS/m-p/567869#M159750</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-21T10:32:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reading out using PUT in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-out-using-PUT-in-SAS/m-p/567873#M159752</link>
      <description>&lt;P&gt;The discrepancy between the numbers of variables in datasets TEST and TC_LEVEL_JUNE01 indicates that the PUT statement uses 870-516=354 variable names that are not contained in&amp;nbsp;TC_LEVEL_JUNE01, i.e., the PUT statement doesn't match the dataset, which is alarming. Even worse, if exactly 516 variable names are listed in the PUT statement, 354 variables from TC_LEVEL_JUNE01 will not be written to JUNE012.csv, only missing values instead. Normally, TEST would be an identical copy of TC_LEVEL_JUNE01 (and therefore typically omitted by using a &lt;FONT face="courier new,courier"&gt;data _null_&lt;/FONT&gt;&amp;nbsp;statement).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Watch out for log messages like&lt;/P&gt;
&lt;PRE&gt;NOTE: Variable NEWVAR is uninitialized.&lt;/PRE&gt;
&lt;P&gt;to identify the mismatching variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, consider using the DSD option (which is useful if a character value happens to contain the delimiter) if you want to create a CSV file and not a text file with fixed field widths and without delimiters (as is suggested by your PUT statement).&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jun 2019 11:15:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-out-using-PUT-in-SAS/m-p/567873#M159752</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-06-21T11:15:39Z</dc:date>
    </item>
  </channel>
</rss>

