<?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 How to retrieve the complete format of variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/356292#M83534</link>
    <description>&lt;P&gt;As far as I know, all items and attributes for features in dataset would be automatically saved in SASHELP.&lt;/P&gt;&lt;P&gt;And I need to use PUT function to create a new variable in the&amp;nbsp;macro. So, I tried to retrieve the variable format (e.g. $SEXOF6.) from SASHELP but it just recorded the char part as "$SEXOF.". Why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a suggestion to retrieve the complete format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 May 2017 10:27:13 GMT</pubDate>
    <dc:creator>JohnChen_TW</dc:creator>
    <dc:date>2017-05-05T10:27:13Z</dc:date>
    <item>
      <title>How to retrieve the complete format of variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/356292#M83534</link>
      <description>&lt;P&gt;As far as I know, all items and attributes for features in dataset would be automatically saved in SASHELP.&lt;/P&gt;&lt;P&gt;And I need to use PUT function to create a new variable in the&amp;nbsp;macro. So, I tried to retrieve the variable format (e.g. $SEXOF6.) from SASHELP but it just recorded the char part as "$SEXOF.". Why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a suggestion to retrieve the complete format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 10:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/356292#M83534</guid>
      <dc:creator>JohnChen_TW</dc:creator>
      <dc:date>2017-05-05T10:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the complete format of variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/356297#M83539</link>
      <description>&lt;P&gt;It depends on how you applied the format to the variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format library=work;
value $mysex
  'M' = 'Male'
  'F' = 'Female'
;
run;

data class;
set sashelp.class;
format sex $mysex6.;
run;

proc sql;
/*create table test as*/
select name, format from dictionary.columns
where libname = 'WORK' and memname = 'CLASS';
quit;

data class1;
set sashelp.class;
format sex $mysex.;
run;

proc sql;
/*create table test as*/
select name, format from dictionary.columns
where libname = 'WORK' and memname = 'CLASS1';
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Look at the result:&lt;/P&gt;
&lt;PRE&gt;Column Name                       Column Format
-----------------------------------------------------------------------------------
Name                                                                               
Sex                               $MYSEX6.                                         
Age                                                                                
Height                                                                             
Weight                                                                             

Column Name                       Column Format
-----------------------------------------------------------------------------------
Name                                                                               
Sex                               $MYSEX.                                          
Age                                                                                
Height                                                                             
Weight                                                                             
&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 May 2017 10:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/356297#M83539</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-05T10:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the complete format of variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/356298#M83540</link>
      <description>&lt;P&gt;We have no way of telling from what you have posted. &amp;nbsp;&lt;U&gt;&lt;STRONG&gt;Post test data in the form of a datastep!&lt;/STRONG&gt;&lt;/U&gt; If you have some code post that, and post what you want out at the end. &amp;nbsp;Sashelp.vcolumn -&amp;gt; Format should contain the format name and length, so how did you define the format as thats not a SAS format.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 10:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/356298#M83540</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-05T10:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the complete format of variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/356339#M83559</link>
      <description>&lt;P&gt;What do you mean by retrieve the complete format? Are you looking for the format definition (ie proc format mapping) or something else?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 12:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/356339#M83559</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-05T12:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the complete format of variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/357085#M83798</link>
      <description>My question is, I cannot know the format of each variable from the external files in advance.&lt;BR /&gt;After googled, I just know that the format will be saved in sashelp.columns. But it will not save the format with the number when the actual format is $SEXOF6..&lt;BR /&gt;&lt;BR /&gt;1. What does the number of formats mean?&lt;BR /&gt;2. How to get the complete format from the external files in advance?</description>
      <pubDate>Tue, 09 May 2017 08:14:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/357085#M83798</guid>
      <dc:creator>JohnChen_TW</dc:creator>
      <dc:date>2017-05-09T08:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the complete format of variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/357091#M83800</link>
      <description>&lt;P&gt;The metadata for external files are NOT to be found in sashelp.&lt;STRONG&gt;v&lt;/STRONG&gt;column or dictionary.columns. Those only deal with SAS datasets in currently assigned libraries. sashelp.column (note the missing v) is a static table supplied at SAS installation time that has nothing to do with current metadata.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by "number of formats"? I can't find such a variable anywhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your question 2, the formats for external files have to be determined &lt;U&gt;by you&lt;/U&gt; from the documentation that accompanies such files. External files without documentation are worthless and should be returned to sender.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For how formats are stored in dictionary.columns (sashelp.vcolumn is just a view to that), see my earlier post.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 08:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/357091#M83800</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-09T08:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to retrieve the complete format of variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/357092#M83801</link>
      <description>&lt;P&gt;There is several parts to your question here. &amp;nbsp;Firstly, for external files you cannot use SAS metadata libraries, that is only for files which appear in assigned libnames. &amp;nbsp;For external files you should have a data transfer specification which details all the structure of the file. &amp;nbsp;If you do not have this then you will be guessing and it is a bad import process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly formats are:&lt;/P&gt;
&lt;P&gt;&amp;lt;type&amp;gt;&amp;lt;name&amp;gt;&amp;lt;length&amp;gt;&lt;/P&gt;
&lt;P&gt;Where type is $ for character and missing for numeric.&lt;/P&gt;
&lt;P&gt;Name is the name of the format.&lt;/P&gt;
&lt;P&gt;Length is the maximum length in characters of the format.&lt;/P&gt;
&lt;P&gt;So&amp;nbsp;&lt;SPAN&gt;$SEXOF6&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Means it is character, called SEXOF, and has a maximum length of 6 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now Where do you get the information that there is a format $SEXOF6? &amp;nbsp;If you can provide complete information -what type of files (examples?) documentation etc. as we are just huessing what your trying to do here.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 08:36:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-retrieve-the-complete-format-of-variable/m-p/357092#M83801</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-09T08:36:57Z</dc:date>
    </item>
  </channel>
</rss>

