<?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 do I use meta data extracted from proc contents to read in obs? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86755#M18531</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Data set t has only name, type and length as well?&lt;/P&gt;&lt;P&gt;It seems weird to want to want to append the contents result to the data you originally ran it on...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyways, assuming it makes sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data addi;&lt;/P&gt;&lt;P&gt;set b;&lt;/P&gt;&lt;P&gt;keep name type length;&lt;/P&gt;&lt;P&gt;*other things go here;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc append base=t data=addi force;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Nov 2012 16:59:56 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2012-11-30T16:59:56Z</dc:date>
    <item>
      <title>how do I use meta data extracted from proc contents to read in obs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86753#M18529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have meta data extracted into data set b like this&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;contents&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; = t&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt; = b&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;noprint&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; color: blue; background: white;"&gt;nodetails&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;in data set b, I just use Name, Type, Length.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Now, I want to create data set "addi" using the data set b, then append the data set addi to data set t.&lt;/P&gt;&lt;P&gt;How do I do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to do this so that appending data set won't have inconsistent length or data type issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Nov 2012 16:00:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86753#M18529</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-11-30T16:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: how do I use meta data extracted from proc contents to read in obs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86754#M18530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you would have to write a macro so that all variables in addi have the same type and length as in data set t.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I'm curious, why don't you just use PROC APPEND with the FORCE option? Does that not work?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Nov 2012 16:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86754#M18530</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2012-11-30T16:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: how do I use meta data extracted from proc contents to read in obs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86755#M18531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Data set t has only name, type and length as well?&lt;/P&gt;&lt;P&gt;It seems weird to want to want to append the contents result to the data you originally ran it on...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyways, assuming it makes sense.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data addi;&lt;/P&gt;&lt;P&gt;set b;&lt;/P&gt;&lt;P&gt;keep name type length;&lt;/P&gt;&lt;P&gt;*other things go here;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc append base=t data=addi force;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Nov 2012 16:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86755#M18531</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-11-30T16:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: how do I use meta data extracted from proc contents to read in obs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86756#M18532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The usual way to copy all the attributes does not bother with a PROC CONTENTS.&amp;nbsp; Instead:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data addi;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if 0 then set t;&lt;/P&gt;&lt;P&gt;&amp;nbsp; * additional statements to read in data to addi;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just having SET T at the start of the program will set up all the variable attributes in exactly the same way they are defined in T.&amp;nbsp; There is no need to actually read in any of the data, hence IF 0 which is always false.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Nov 2012 19:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86756#M18532</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-11-30T19:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: how do I use meta data extracted from proc contents to read in obs?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86757#M18533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I recommend just using PROC APPEND, but assuming you only have dataset B you can use that to generate a LENGTH statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; select catx(' ',name,cats(case when (type=2) then '$' else ' ' end,length))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :varlist separated by ' '&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data addi;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; length &amp;amp;varlist ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; .... code to populate variables&amp;nbsp; .... ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be better to include VARNUM in the metadata so that you could create the variables in the proper order. (Note generating macro variable DUMMY to suppress SQL message when order variable not included in the SELECT list.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc sql noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; select catx(' ',name,cats(case when (type=2) then '$' else ' ' end,length))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , varnum&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into :varlist separated by ' '&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , dummy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; order by varnum&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Dec 2012 17:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-do-I-use-meta-data-extracted-from-proc-contents-to-read-in/m-p/86757#M18533</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-12-01T17:57:04Z</dc:date>
    </item>
  </channel>
</rss>

