<?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: Need to store Dataset encoding type into variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/608242#M176992</link>
    <description>&lt;P&gt;You can try using the dictionary tables, e.g.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
   select
      encoding
   into
      :encoding
   from
      dictionary.tables
   where
          libname eq 'SASHELP'
      and memname eq 'CLASS'
   ;
quit;

%put encoding = &amp;amp;encoding;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
    <pubDate>Fri, 29 Nov 2019 13:25:38 GMT</pubDate>
    <dc:creator>Amir</dc:creator>
    <dc:date>2019-11-29T13:25:38Z</dc:date>
    <item>
      <title>Need to store Dataset encoding type into variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/608240#M176990</link>
      <description>&lt;P&gt;Hi Friends,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I need to capture the encoding type of dataset in 1 macro variable for further process.&lt;/P&gt;&lt;P&gt;Proc contents is displaying encoding type&amp;nbsp;in .lst file . I need to capture it in one variable .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can we find encoding type of dataset in any internal SAS metadata&amp;nbsp;dataset&amp;nbsp; ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sasikala.k&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 13:12:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/608240#M176990</guid>
      <dc:creator>sasikala</dc:creator>
      <dc:date>2019-11-29T13:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need to store Dataset encoding type into variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/608241#M176991</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/113481"&gt;@sasikala&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	set sashelp.vtable;
	where lowcase(libname)="my_lib" and lowcase(memname)="my_dataset"; /*specify your library and your dataset names*/
	call symputx("encoding",encoding);
run;

%put &amp;amp;encoding;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Nov 2019 13:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/608241#M176991</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-11-29T13:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need to store Dataset encoding type into variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/608242#M176992</link>
      <description>&lt;P&gt;You can try using the dictionary tables, e.g.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
   select
      encoding
   into
      :encoding
   from
      dictionary.tables
   where
          libname eq 'SASHELP'
      and memname eq 'CLASS'
   ;
quit;

%put encoding = &amp;amp;encoding;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 13:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/608242#M176992</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2019-11-29T13:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Need to store Dataset encoding type into variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/608265#M176997</link>
      <description>&lt;P&gt;You can use ODS OUTPUT to have SAS save a dataset out of the information it prints.&amp;nbsp; (Use ODS TRACE to figure out what the outputs are named).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods output attributes=attributes;
proc contents data=sashelp.class; run;
proc print data=attributes; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34323iD9A953B9F0994CAE/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set attributes;
  where label1='Encoding';
  call symputx('encoding',cValue1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you can query the metadata table TABLES.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select libname,memname,encoding
from dictionary.tables where libname='SASHELP' and memname='CLASS'
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 451px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34324i6FAB3C8ABB0167E0/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select encoding into :encoding trimmed
from dictionary.tables where libname='SASHELP' and memname='CLASS'
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you might want to remove the descriptive part of that text if you want a value you could actually use in code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let encoding=%scan(&amp;amp;encoding,-1,());&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Nov 2019 15:23:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/608265#M176997</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-29T15:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need to store Dataset encoding type into variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/609027#M177295</link>
      <description>&lt;P&gt;Thanks All !.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2019 12:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/609027#M177295</guid>
      <dc:creator>sasikala</dc:creator>
      <dc:date>2019-12-03T12:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Need to store Dataset encoding type into variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/609028#M177296</link>
      <description>&lt;P&gt;Hi Guys !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; One more requirement, I needed get the CPORT or XPORT file encoding and store it in another variable .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Any idea ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sasikala.k&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2019 12:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/609028#M177296</guid>
      <dc:creator>sasikala</dc:creator>
      <dc:date>2019-12-03T12:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need to store Dataset encoding type into variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/609099#M177311</link>
      <description>&lt;P&gt;Does the XPORT format even support encoding?&lt;/P&gt;
&lt;PRE&gt;47    filename x temp;
48    libname x xport;
NOTE: Libref X was successfully assigned as follows:
      Engine:        XPORT
      Physical Name: ...\#LN00057
49    data x.class(encoding='utf8'); set sashelp.class; run;
                   --------
                   76

WARNING 76-63: The option ENCODING is not implemented in the XPORT engine.

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set X.CLASS has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.00 seconds
&lt;/PRE&gt;
&lt;P&gt;For CPORT files you will probably need to first use CIMPORT to create actual datasets out of them and then check that dataset's encoding.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2019 15:56:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/609099#M177311</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-03T15:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need to store Dataset encoding type into variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/631197#M186987</link>
      <description>Thanks Tom.</description>
      <pubDate>Wed, 11 Mar 2020 10:56:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-store-Dataset-encoding-type-into-variable/m-p/631197#M186987</guid>
      <dc:creator>sasikala</dc:creator>
      <dc:date>2020-03-11T10:56:47Z</dc:date>
    </item>
  </channel>
</rss>

