<?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: Creating a format from an imported table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984063#M379645</link>
    <description>&lt;P&gt;Hi thanks for your help it now runs!&lt;/P&gt;</description>
    <pubDate>Wed, 25 Feb 2026 18:32:10 GMT</pubDate>
    <dc:creator>beverlyam</dc:creator>
    <dc:date>2026-02-25T18:32:10Z</dc:date>
    <item>
      <title>Creating a format from an imported table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984054#M379638</link>
      <description>&lt;P&gt;I am trying to create a format based on a table that I imported into SAS. The table includes ICD 10 codes as once variable and the corresponding description as the other variable. I am trying to create a format that would call out the code and description as one. I am calling the format is&amp;nbsp;&lt;EM&gt;icdalpha&lt;/EM&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far this is what I have come up with but I continue to get errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc import datafile= 'O:\Data Dictionaries\All ICD9_10 Diagnosis Codes Dec 2025.xlsx' &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;OUT=DX&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;DBMS=xlsx &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;REPLACE;SHEET="Formatted";&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;GETNAMES=YES;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;RUN;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data dx2;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;set dx;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;/* Rename columns to match SAS format requirements */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;retain fmtname "icdalpha"; /* The name of your future format */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;rename CODE = start&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;SHORT__DESC = label;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data dx2_clean;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;set dx2;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;/* Remove rows where the code is missing */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if missing(start) then delete;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;/* Clean up the values */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;start = upcase(strip(start));&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;label = strip(label);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data=dx2_clean nodupkey;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;by start;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data dx2_final;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;set dx2_clean;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;/* 1. Remove rows where the code is missing or just a blank string */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if compress(start) in ('', '.') then delete;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* 2. Ensure everything is Upper Case to avoid 'a1' vs 'A1' conflicts */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;start = upcase(strip(start));&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* 3. Remove any remaining duplicates of the same code */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;proc sort data=dx2_final nodupkey;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;by start;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/* 4. Build the format */&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;proc format cntlin=dx2_final;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help in trying to figure out where I am going wrong. I have attached the table I am using.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2026 16:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984054#M379638</guid>
      <dc:creator>beverlyam</dc:creator>
      <dc:date>2026-02-25T16:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a format from an imported table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984055#M379639</link>
      <description>&lt;P&gt;It does not look like the file is attached. However, if the Start/Code variable is character, you need to create a character format as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dx2;
set dx;

/* Rename columns to match SAS format requirements */
retain fmtname "$icdalpha"; /* The name of your future format */
rename CODE = start
SHORT__DESC = label;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you continue to have problems, please send the log that shows the Error messages you are getting.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2026 17:09:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984055#M379639</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2026-02-25T17:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a format from an imported table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984056#M379640</link>
      <description>&lt;P&gt;What errors do you get?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some examples:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_072/proc/n1e19y6lrektafn1kj6nbvhus59w.htm" target="_blank"&gt;SAS Help Center: Creating a Format from a CNTLIN= Data Set&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://go.documentation.sas.com/doc/en/proc/3.2/n1e19y6lrektafn1kj6nbvhus59w.htm" target="_blank"&gt;SAS Help Center: Example: PROC FORMAT Creating a Format from a Data Set&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2026 17:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984056#M379640</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2026-02-25T17:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a format from an imported table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984057#M379641</link>
      <description>&lt;P&gt;The table is now attached&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2026 17:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984057#M379641</guid>
      <dc:creator>beverlyam</dc:creator>
      <dc:date>2026-02-25T17:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a format from an imported table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984058#M379642</link>
      <description>&lt;P&gt;Best practice when code generates errors is to include the LOG with the code and error, warning or other messages of concern. Copy the text from the log, on the forum open a text box window using the &amp;lt;/&amp;gt; icon above the main message window and paste the code and messages. The text box is important because the forum software will refomat text pasted into the main message window resulting in some of the diagnostic information that SAS often supplies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a minimum your code should also include a TYPE variable to tell SAS whether the valus in the START variable are numeric or character and display or input. A type of N (character value of the variable type) means Start is supposed to be numeric and is a display format, Type of C means start is Character and is a display format, Type of I (upper case i) is informat for numeric values, type of J is informat for character values, Type P means a PICTURE format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data contains "A1" and "a1" for the variable and want them both to display the same label text then you want both values in the START.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because you IMPORT the data from Excel you may have issues of same value, i.e. "A1" with multiple values of the label cause by capitalization differences or white space in values (different numbers of spaces can be hard to see) or leading spaces. SAS doesn't like that for formats or informats and will show errors of duplicated ranges.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suggestion: Write a small, as in two or there value/invalue statements as normal proc format code and use the CNTLOUT option to write a data set of those. That will show values for the variables needed in the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to consider adding and Other = error option to the above example trial code if creating an INFORMAT. The Other option, which would go into a variable named HLO, coupled with the error option means that use of the format with unknown or unexpected values tells you that such a value was encountered in the log with an invalid data message.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2026 17:19:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984058#M379642</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2026-02-25T17:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a format from an imported table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984059#M379643</link>
      <description>&lt;P&gt;Your variables are character, so you need to create a character format:&lt;/P&gt;
&lt;P&gt;retain fmtname &lt;STRONG&gt;"$icdalpha"&lt;/STRONG&gt;; /* The name of your future format */&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dx2;
set dx;

/* Rename columns to match SAS format requirements */
retain fmtname "$icdalpha"; /* The name of your future format */
rename CODE = start
SHORT__DESC = label;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Feb 2026 17:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984059#M379643</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2026-02-25T17:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a format from an imported table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984063#M379645</link>
      <description>&lt;P&gt;Hi thanks for your help it now runs!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Feb 2026 18:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-format-from-an-imported-table/m-p/984063#M379645</guid>
      <dc:creator>beverlyam</dc:creator>
      <dc:date>2026-02-25T18:32:10Z</dc:date>
    </item>
  </channel>
</rss>

