<?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: Apply Format before exporting to sas7bdat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771135#M244669</link>
    <description>&lt;P&gt;Run a PROC CONTENTS to determine where custom formats are used.&lt;/P&gt;
&lt;P&gt;Then run a DATA step where you use PUT or VVALUE functions to convert raw values to formatted values, or where you simply remove formats that don't do anything special (e.g. currency formats). Take care to create new variables with sufficient length.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Sep 2021 13:52:30 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-09-29T13:52:30Z</dc:date>
    <item>
      <title>Apply Format before exporting to sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771100#M244645</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a python script that needs to read data, and, for some reason (related to our python pipeline) we have to read a single file.&lt;/P&gt;&lt;P&gt;When exporting SAS data containing formats with labels, two files are exported (sas7bdat for the data without applying the labels, sas7bcat for the catalog containing the labels).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to export the sas7bdat file with the data containing the labels applied ; could you please help me with the correct approach for this ?&lt;/P&gt;&lt;P&gt;(I really couldn't find a clear answer ; seems that put(data_column, $format_name) does it for one column but I would like a synthetic way to get this done in one shot on all columns at the export).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks !!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 10:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771100#M244645</guid>
      <dc:creator>guillaume_bs</dc:creator>
      <dc:date>2021-09-29T10:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Format before exporting to sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771106#M244650</link>
      <description>Please post the code of loading the data from Pytom to sas.&lt;BR /&gt;I assume it can be done by adapting that code.</description>
      <pubDate>Wed, 29 Sep 2021 10:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771106#M244650</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-09-29T10:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Format before exporting to sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771112#M244652</link>
      <description>Thanks Shmuel for your message.&lt;BR /&gt;&lt;BR /&gt;I use the pyreadstat library (wrapping the readstat C library).&lt;BR /&gt;I know it can read data and catalog simultaneously, to apply the catalog, as stated here : &lt;A href="https://github.com/Roche/pyreadstat#reading-value-labels" target="_blank"&gt;https://github.com/Roche/pyreadstat#reading-value-labels&lt;/A&gt; with the function pyreadstat.read_sas7bdat('data.sas7bdat', catalog_file='catalog.sas7bcat', ...)&lt;BR /&gt;&lt;BR /&gt;My problem is that I can only bring the sas7bdat file to this function and my pipeline doesn't allow me to get any sas7bcat file.&lt;BR /&gt;So the formating should be applied when generating the sas7bdat file.&lt;BR /&gt;&lt;BR /&gt;I hope my question is clearer with these details,&lt;BR /&gt;Thanks !!</description>
      <pubDate>Wed, 29 Sep 2021 11:50:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771112#M244652</guid>
      <dc:creator>guillaume_bs</dc:creator>
      <dc:date>2021-09-29T11:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Format before exporting to sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771115#M244655</link>
      <description>&lt;P&gt;If the dataset has formats applied to columns, and the formats are not available, then you are stuck with the raw (unformatted) values.&lt;/P&gt;
&lt;P&gt;If the Python module cannot deal with such an event, you need to ask the source for the dataset to remove the formats before sending you the dataset.&lt;/P&gt;
&lt;P&gt;If this is for non-commercial purposes, you could do that yourself with SAS On Demand.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 12:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771115#M244655</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-29T12:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Format before exporting to sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771124#M244660</link>
      <description>Thanks Kurt !&lt;BR /&gt;Yes the situation you describe is exactly what I am facing.&lt;BR /&gt;Right now, most of the time, the datasets passed don't have any format applied, so there is no loss in the sas7bdat file and it works fine.&lt;BR /&gt;Some times, there was a format applied and it gets lost when only the sas7bdat file is used.&lt;BR /&gt;&lt;BR /&gt;My question (it is probably a dumb SAS question) would be : when exporting the file, what should be done to apply the format ? (so the sas7bdat file contains the well-formated data and the sas7bdat file is basically empty)</description>
      <pubDate>Wed, 29 Sep 2021 12:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771124#M244660</guid>
      <dc:creator>guillaume_bs</dc:creator>
      <dc:date>2021-09-29T12:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Format before exporting to sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771135#M244669</link>
      <description>&lt;P&gt;Run a PROC CONTENTS to determine where custom formats are used.&lt;/P&gt;
&lt;P&gt;Then run a DATA step where you use PUT or VVALUE functions to convert raw values to formatted values, or where you simply remove formats that don't do anything special (e.g. currency formats). Take care to create new variables with sufficient length.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 13:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771135#M244669</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-29T13:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Format before exporting to sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771406#M244793</link>
      <description>Thanks a lot Kurt.&lt;BR /&gt;Yes applying the put(...) function to the data to get the format applied &amp;amp; stored in the data itself produces the expected result indeed.&lt;BR /&gt;I was wondering if there was a way to avoid doing it explicitly and just dump the data with all columns replaced with their "formatted equivalent".&lt;BR /&gt;If there is no way to do that I'll use the explicit put(...) to create new, formatted columns as you suggest.&lt;BR /&gt;&lt;BR /&gt;Thanks for your help !</description>
      <pubDate>Thu, 30 Sep 2021 15:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771406#M244793</guid>
      <dc:creator>guillaume_bs</dc:creator>
      <dc:date>2021-09-30T15:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Format before exporting to sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771414#M244799</link>
      <description>&lt;P&gt;Why not just dump the data to a text file.&amp;nbsp; That will preserve the formatting since everything will be text.&amp;nbsp; Then send the text file to your Python code instead of the SAS dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why does it matter?&amp;nbsp; What is the format doing?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the format is just doing a one to one replacement of the raw value with some decoded text why not just use the raw (coded) values in your Python code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you somehow using the format to collapse the raw data so that multiple distinct raw values are mapped into a single formatted value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 16:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771414#M244799</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-30T16:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Format before exporting to sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771434#M244811</link>
      <description>&lt;P&gt;You could use PROC PRINT and ODS OUTPUT to redirect the formatted values to a new dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 17:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apply-Format-before-exporting-to-sas7bdat/m-p/771434#M244811</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-30T17:41:12Z</dc:date>
    </item>
  </channel>
</rss>

