<?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: Running SAS Program to Add CCSR Categories to NIS Data in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738057#M9947</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As shown in the following log, I think the problem is that in the first proc sort that creates WORK.NIS_2018_CORESKINNY, the non-existent variables KEY and DBTYPE are specified in the DROP, KEEP, or RENAME statements.&lt;BR /&gt;The following errors may be caused by the failure to create the dataset there, so could you please provide the program you ran and the sample data?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;
&lt;P&gt;ERROR: The variable DBTYPE in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;
&lt;P&gt;WARNING: The data set WORK.NIS_2018_CORESKINNY may be incomplete.When this step was stopped there were 0 observations and 0&lt;/P&gt;
&lt;P&gt;variables.&lt;/P&gt;
&lt;P&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;/P&gt;
&lt;P&gt;real time0.01 seconds&lt;/P&gt;
&lt;P&gt;cpu time0.00 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Fri, 30 Apr 2021 00:46:10 GMT</pubDate>
    <dc:creator>japelin</dc:creator>
    <dc:date>2021-04-30T00:46:10Z</dc:date>
    <item>
      <title>Running SAS Program to Add CCSR Categories to NIS Data</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738053#M9946</link>
      <description>&lt;P&gt;Dear SAS Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been struggling with my SAS Program to add Clinical Classifications Software Refined (CCSR) for ICD-10 CM diagnosis on to my National Inpatient Sample (NIS) core dataset. I have modified all the parts of the program as instructed in the DXCCSR user guide. Unfortunately I keep getting error messages.&lt;/P&gt;&lt;P&gt;Please find below a sample of my modifications to the program and a snap shot of the error messages.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* FILE LOCATIONS ;&lt;BR /&gt;FILENAMe INRAW1 '/folders/myfolders/HCUP/NIS2018/DXCCSR_v2021-2.csv' lRECL=3000; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;LIBNAME IN1 '/folders/myfolders/HCUP/NIS2018'; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;LIBNAME OUT1 '/folders/myfolders/HCUP/NIS2018/NIS'; *&amp;lt;=== USER MUST MODIFY;&lt;/P&gt;&lt;P&gt;* OPTIONAL FILES ;&lt;BR /&gt;* Build vertical file? 1=yes, 0=no; %LET VERT=1; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Build default DXCCSR file? 1=yes, 0=no; %LET DFLT=1; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Build horizontal file? 1=yes, 0=no; %LET HORZ=0; *&amp;lt;=== USER MUST MODIFY;&lt;/P&gt;&lt;P&gt;* FILE NAMES ;&lt;BR /&gt;* Input SAS file member name; %LET CORE=NIS_2018_CORE; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Output SAS file name, vertical; %LET VERTFILE=NIS_CORE_OUTPUT_VERT; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Output SAS file name, horizontal; %LET HORZFILE=OUTPUT_HORZ_FILE_NAME; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Output SAS file name, default DXCCSR; %LET DFLTFILE=OUTPUT_DFLT_FILE_NAME; *&amp;lt;=== USER MUST MODIFY;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* INPUT DATA CHARACTERISTICS ;&lt;BR /&gt;* Database types, IP/OP/IO; %LET DBTYPE=IP; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Data element to identify IP/OP records; %LET IOVAR=DBTYPE; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Data value to identify IP records; %LET IOVALI=IP; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Data value to identify OP records; %LET IOVALO=OP; *&amp;lt;=== USER MUST;&lt;BR /&gt;* Linking key on input SAS data; %LET RECID=KEY; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Prefix of diagnosis variables; %LET DXPREFIX=I10_DX; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Maximum number of DXs on any record; %LET NUMDX=40; *&amp;lt;=== USER MUST MODIFY;&lt;BR /&gt;* Record specific DX Count variable, if not available leave it blank;&lt;BR /&gt;%LET NDXVAR=I10_NDX; *&amp;lt;=== USER MUST MODIFY;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error Messages&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;ERROR: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ERROR: The variable DBTYPE in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;WARNING: The data set WORK.NIS_2018_CORESKINNY may be incomplete.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;When this step was stopped there were 0 observations and 0&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;variables.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;real time&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cpu time&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ERROR: BY variable KEY is not on input data set WORK.NIS_2018_CORESKINNY.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;WARNING: The data set WORK.IP_IN may be incomplete.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;When this step was stopped there were 0 observations and 0 variables.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;real time&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cpu time&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;711:160&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;711:74&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: Variable KEY is uninitialized.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: Variable I10_NDX is uninitialized.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ERROR: BY variable KEY is not on input data set WORK.IP_IN.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;WARNING: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;WARNING: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;WARNING: The data set WORK.IP_OUT_VT may be incomplete.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;When this step was stopped there were 0 observations and 4 variables.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;WARNING: The data set WORK.DXCCSR_FLAGS may be incomplete.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;When this step was stopped there were 0 observations and 3 variables.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;real time&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;0.03 seconds&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cpu time&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;0.04 seconds&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;ERROR: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;WARNING: The data set WORK.IP_OUT_VT may be incomplete.&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;When this step was stopped there were 0 observations and 4 variables.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;WARNING: Data set WORK.IP_OUT_VT was not replaced because this step was stopped.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;real time&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;cpu time&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: Variable KEY not found.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: BY variable KEY is not on input data set WORK.IP_OUT_VT.&lt;/P&gt;&lt;P&gt;ERROR: Variable KEY not found.&lt;/P&gt;&lt;P&gt;ERROR: Invalid value for the SORTEDBY option.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: BY variable KEY is not on input data set WORK.DXCCSR_FLAGS.&lt;/P&gt;&lt;P&gt;ERROR: BY variable KEY is not on input data set WORK.IP_DFLT_FILE.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ERROR: BY variable KEY is not on input data set WORK.IP_DFLT_FILE.&lt;/P&gt;&lt;P&gt;ERROR: Variable KEY not found.&lt;/P&gt;&lt;P&gt;ERROR: Invalid value for the SORTEDBY option.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Please does&amp;nbsp;anyone know what might be wrong?&amp;nbsp;I am quite new to SAS. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, if anyone has any experience using the NIS dataset, please hit me up.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 00:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738053#M9946</guid>
      <dc:creator>ededeStats</dc:creator>
      <dc:date>2021-04-30T00:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Running SAS Program to Add CCSR Categories to NIS Data</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738057#M9947</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;As shown in the following log, I think the problem is that in the first proc sort that creates WORK.NIS_2018_CORESKINNY, the non-existent variables KEY and DBTYPE are specified in the DROP, KEEP, or RENAME statements.&lt;BR /&gt;The following errors may be caused by the failure to create the dataset there, so could you please provide the program you ran and the sample data?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;
&lt;P&gt;ERROR: The variable DBTYPE in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;
&lt;P&gt;WARNING: The data set WORK.NIS_2018_CORESKINNY may be incomplete.When this step was stopped there were 0 observations and 0&lt;/P&gt;
&lt;P&gt;variables.&lt;/P&gt;
&lt;P&gt;NOTE: PROCEDURE SORT used (Total process time):&lt;/P&gt;
&lt;P&gt;real time0.01 seconds&lt;/P&gt;
&lt;P&gt;cpu time0.00 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Fri, 30 Apr 2021 00:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738057#M9947</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-30T00:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Running SAS Program to Add CCSR Categories to NIS Data</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738058#M9948</link>
      <description>&lt;P&gt;You need to supply a complete SAS log including both source code and error messages and notes. Post it using the &amp;lt;/&amp;gt; icon. Without that we would just be guessing what your code does.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 00:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738058#M9948</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-04-30T00:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Running SAS Program to Add CCSR Categories to NIS Data</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738065#M9949</link>
      <description>&lt;PRE&gt; 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         /******************************************************************/
 74         /* Title:       CCSR FOR ICD-10-CM DIAGNOSIS MAPPING PROGRAM      */
 75         /*                                                                */
 76         /* Program:     DXCCSR_Mapping_Program_v2021-2.SAS                */
 77         /*                                                                */
 78         /* Description: This is the SAS mapping program to apply   */
 79         /*  the CCSR to the user�s ICD-10-CM-coded data.       */
 80         /*  The mapping program includes two options           */
 81         /*  for the file structure of CCSR output.              */
 82         /*                                                                */
 83         /*              There are two general sections to this program:   */
 84         /*                                                                */
 85         /*              1) The first section creates temporary SAS        */
 86         /*                 informats using the DXCCSR CSV file.           */
 87         /*                 These informats are used in step 2 to create   */
 88         /*                 the CCSR variables in the output files.        */
 89         /*                 output files.                                  */
 90         /*              2) The second section loops through the diagnosis */
 91         /*                 array in your SAS dataset and assigns          */
 92         /*                 CCSR categories in the output files.           */
 93         /*                                                                */
 94         /*              Starting with v2021-1 of the CCSR, the SAS program*/
 95         /*              and accompanying CSV file include a separate      */
 96         /*              assignment of the default CCSR for inpatient data */
 97         /*              (principal diagnosis) and outpatient data (first- */
 98         /*              listed diagnosis). This feature requires that the */
 99         /*              user identifies whether the input data is only    */
 100        /*              inpatient (IP), only outpatient (OP), or a        */
 101        /*              mixture of inpatient and outpatient data (IO).    */
 102        /*              The v2021-1 (and later) SAS program cannot be used*/
 103        /*              with the prior versions of the DXCCSR CSV file.   */
 104        /*                                                                */
 105        /*              The v2021-2 CSV file is compatible with ICD-10-CM */
 106        /*              diagnosis codes from October 2015 through         */
 107        /*              September 2021.                                   */
 108        /*                                                                */
 109        /* Output:      The program always outputs a vertical file.       */
 110        /*              + Vertical file's layout: RECID DXCCSR DX_POSITION*/
 111        /*                         DEFAULT_DXCCSR(Y, N, X, or Blank)      */
 112        /*                         DXCCSR_VERSION                         */
 113        /*                                                                */
 114        /*        The user can select to output two additional files*/
 115        /*              + Horizontal file's layout: RECID DXCCSR_BBBNNN   */
 116        /*                         DXCCSR_DEFAULT_DX1  DXCCSR_VERSION     */
 117        /*              where BBB=3-letter body system abbreviation,   */
 118        /*                     NNN=3-digit number                         */
 119        /*              + Default file's layout: RECID DXCCSR_DEFAULT_DX1 */
 120        /*                         DXCCSR_VERSION                         */
 121        /******************************************************************/
 122        
 123        /******************************************************************/
 124        /*  Macro Variables that must be set to define the characteristics*/
 125        /*  of your SAS discharge data. Change these values to match the  */
 126        /*  number of diagnoses in your dataset. Change CORE to match the */
 127        /*  name of your dataset. Set DXPREFIX to be the fixed part of    */
 128        /*  the diagnosis variables. For example, if the diagnosis        */
 129        /*  variables in your SAS dataset are I10_DX1, I10_DX2, ... then  */
 130        /*  set DXPREFIX to I10_DX.                                       */
 131        /******************************************************************/
 132        %Let obs_ = MAX;                                                           *&amp;lt;=== Use smaller number for testing;
 133        
 134        * FILE LOCATIONS ;
 135        FILENAMe INRAW1  '/folders/myfolders/HCUP/NIS2018/DXCCSR_v2021-2.csv'   lRECL=3000;  *&amp;lt;=== USER MUST MODIFY;
 136        LIBNAME  IN1     '/folders/myfolders/HCUP/NIS2018';
 NOTE: Libref IN1 was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders/HCUP/NIS2018
 136      !                                                                           *&amp;lt;=== USER MUST MODIFY;
 137        LIBNAME  OUT1    '/folders/myfolders/HCUP/NIS2018/NIS';
 NOTE: Libref OUT1 was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders/HCUP/NIS2018/NIS
 137      !                                                                                 *&amp;lt;=== USER MUST MODIFY;
 138        
 139        * OPTIONAL FILES ;
 140        * Build vertical file? 1=yes, 0=no;           %LET VERT=1;                          *&amp;lt;=== USER MUST MODIFY;
 141        * Build default DXCCSR file? 1=yes, 0=no;     %LET DFLT=0;                          *&amp;lt;=== USER MUST MODIFY;
 142        * Build horizontal file? 1=yes, 0=no;         %LET HORZ=0;                          *&amp;lt;=== USER MUST MODIFY;
 143        
 144        * FILE NAMES ;
 145        * Input SAS file member name;                 %LET CORE=NIS_2018_CORE;             *&amp;lt;=== USER MUST MODIFY;
 146        * Output SAS file name, vertical;             %LET VERTFILE=NIS_CORE_OUTPUT_VERT;  *&amp;lt;=== USER MUST MODIFY;
 147        * Output SAS file name, horizontal;           %LET HORZFILE=OUTPUT_HORZ_FILE_NAME;  *&amp;lt;=== USER MUST MODIFY;
 148        * Output SAS file name, default DXCCSR;       %LET DFLTFILE=OUTPUT_DFLT_FILE_NAME;  *&amp;lt;=== USER MUST MODIFY;
 149        
 150        * INPUT DATA CHARACTERISTICS ;
 151        * Database types, IP/OP/IO;                   %LET DBTYPE=IP;                       *&amp;lt;=== USER MUST MODIFY;
 152        * Data element to identify IP/OP records;     %LET IOVAR=DBTYPE;                    *&amp;lt;=== USER MUST MODIFY;
 153        * Data value to identify IP records;          %LET IOVALI=IP;                       *&amp;lt;=== USER MUST MODIFY;
 154        * Data value to identify OP records;          %LET IOVALO=OP;                       *&amp;lt;=== USER MUST;
 155        * Linking key on input SAS data;              %LET RECID=KEY;                       *&amp;lt;=== USER MUST MODIFY;
 156        * Prefix of diagnosis variables;              %LET DXPREFIX=I10_DX;                 *&amp;lt;=== USER MUST MODIFY;
 157        * Maximum number of DXs on any record;        %LET NUMDX=40;                        *&amp;lt;=== USER MUST MODIFY;
 158        * Record specific DX Count variable, if not available leave it blank;
 159                                                      %LET NDXVAR=I10_NDX;                  *&amp;lt;=== USER MUST MODIFY;
 160        
 161        TITLE1 'CREATE ICD-10-CM DXCCSR TOOL CATEGORIES';
 162        TITLE2 'USE WITH DISCHARGE ADMINISTRATIVE DATA THAT HAS ICD-10-CM CODES';
 163        
 164        /******************* SECTION 1: CREATE INFORMATS ****************************/
 165        /*  SAS Load the CCSR CSV file &amp;amp; convert into temporary SAS informats that  */
 166        /*  will be used to assign the DXCCSR variables in the next step.           */
 167        /****************************************************************************/
 168        %LET CCSRN_ = 6;
 169        DATA DXCCSR;
 170            LENGTH LABEL $1140;
 171            INFILE INRAW1 DSD DLM=',' END = EOF FIRSTOBS=2;
 172            INPUT
 173               START             : $CHAR7.
 174               I10Label          : $CHAR124.
 175               I10CCSRDeftIP     : $10.
 176               I10CCSRLabelDeftIP: $CHAR228.
 177               I10CCSRDeftOP     : $10.
 178               I10CCSRLabelDeftOP: $CHAR228.
 179               I10CCSR1          : $10.
 180               I10CCSRLabel1     : $CHAR228.
 181               I10CCSR2          : $10.
 182               I10CCSRLabel2     : $CHAR228.
 183               I10CCSR3          : $10.
 184               I10CCSRLabel3     : $CHAR228.
 185               I10CCSR4          : $10.
 186               I10CCSRLabel4     : $CHAR228.
 187               I10CCSR5          : $10.
 188               I10CCSRLabel5     : $CHAR228.
 189               I10CCSR6          : $10.
 190               I10CCSRLabel6     : $CHAR228.
 191            ;
 192        
 193           RETAIN HLO " " FMTNAME "$DXCCSR" TYPE  "J" ;
 194        
 195           LABEL = CATX("#", OF I10CCSR1-I10CCSR6, OF I10CCSRLabel1-I10CCSRLabel6) ;
 196           OUTPUT;
 197        
 198           IF EOF THEN DO ;
 199              START = " " ;
 200              LABEL = " " ;
 201              HLO   = "O";
 202              OUTPUT ;
 203           END ;
 204        RUN;
 
 NOTE: The infile INRAW1 is:
       Filename=/folders/myfolders/HCUP/NIS2018/DXCCSR_v2021-2.csv,
       Owner Name=root,Group Name=vboxsf,
       Access Permission=-rwxrwx---,
       Last Modified=04 March 2021 11:01:46,
       File Size (bytes)=20053092
 
 NOTE: 73211 records were read from the infile INRAW1.
       The minimum record length was 93.
       The maximum record length was 594.
 NOTE: The data set WORK.DXCCSR has 73212 observations and 22 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.51 seconds
       cpu time            0.37 seconds
       
 
 205        
 206        PROC FORMAT LIB=WORK CNTLIN = DXCCSR;
 NOTE: Informat $DXCCSR is already on the library WORK.FORMATS.
 NOTE: Informat $DXCCSR has been output.
 207        RUN;
 
 NOTE: PROCEDURE FORMAT used (Total process time):
       real time           0.18 seconds
       cpu time            0.19 seconds
       
 NOTE: There were 73212 observations read from the data set WORK.DXCCSR.
 
 208        
 209        DATA DXCCSRL(KEEP=START LABEL FMTNAME TYPE HLO);
 210          SET DXCCSR(KEEP=I10CCSR:) END=EOF;
 211        
 212          RETAIN HLO " " FMTNAME "$DXCCSRL" TYPE  "J" ;
 213        
 214          ARRAY CCSRC(&amp;amp;CCSRN_) I10CCSR1-I10CCSR&amp;amp;CCSRN_;
 215          ARRAY CCSRL(&amp;amp;CCSRN_) I10CCSRLabel1-I10CCSRLabel&amp;amp;CCSRN_;
 216        
 217          LENGTH START $6 LABEL $228;
 218          DO I=1 to &amp;amp;CCSRN_;
 219            IF NOT MISSING(CCSRC(I)) then do;
 220              START=CCSRC(I);
 221              LABEL=CCSRL(I);
 222              output;
 223            end;
 224          end;
 225        
 226          IF EOF THEN DO ;
 227             START = " " ;
 228             LABEL = " " ;
 229             HLO   = "O";
 230             OUTPUT;
 231          END;
 232        run;
 
 NOTE: There were 73212 observations read from the data set WORK.DXCCSR.
 NOTE: The data set WORK.DXCCSRL has 83466 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.07 seconds
       cpu time            0.07 seconds
       
 
 233        
 234        PROC SORT DATA=DXCCSRL NODUPKEY;
 235          BY START;
 236        RUN;
 
 NOTE: There were 83466 observations read from the data set WORK.DXCCSRL.
 NOTE: 82925 observations with duplicate key values were deleted.
 NOTE: The data set WORK.DXCCSRL has 541 observations and 5 variables.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           0.03 seconds
       cpu time            0.04 seconds
       
 
 237        
 238        PROC FORMAT LIB=WORK CNTLIN = DXCCSRL;
 NOTE: Informat $DXCCSRL is already on the library WORK.FORMATS.
 NOTE: Informat $DXCCSRL has been output.
 239        RUN;
 
 NOTE: PROCEDURE FORMAT used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 NOTE: There were 541 observations read from the data set WORK.DXCCSRL.
 
 240        
 241        DATA DXCCSRDEFT(KEEP=START LABEL FMTNAME TYPE HLO);
 242          SET DXCCSR(KEEP=START I10CCSRDeftIP rename=(I10CCSRDeftIP=LABEL)) END=EOF;
 243        
 244          RETAIN HLO " " FMTNAME "$DXCCSRDIP" TYPE  "J" ;
 245          output;
 246          IF EOF THEN DO ;
 247             START = " " ;
 248             LABEL = " " ;
 249             HLO   = "O";
 250             OUTPUT;
 251          END;
 252        run;
 
 NOTE: There were 73212 observations read from the data set WORK.DXCCSR.
 NOTE: The data set WORK.DXCCSRDEFT has 73213 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.03 seconds
       cpu time            0.03 seconds
       
 
 253        
 254        PROC SORT DATA=DXCCSRDEFT NODUPKEY; BY START; RUN;
 
 NOTE: There were 73213 observations read from the data set WORK.DXCCSRDEFT.
 NOTE: 1 observations with duplicate key values were deleted.
 NOTE: The data set WORK.DXCCSRDEFT has 73212 observations and 5 variables.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           0.02 seconds
       cpu time            0.02 seconds
       
 
 255        
 256        PROC FORMAT LIB=WORK CNTLIN = DXCCSRDEFT;
 NOTE: Informat $DXCCSRDIP is already on the library WORK.FORMATS.
 NOTE: Informat $DXCCSRDIP has been output.
 257        RUN;
 
 NOTE: PROCEDURE FORMAT used (Total process time):
       real time           0.10 seconds
       cpu time            0.11 seconds
       
 NOTE: There were 73212 observations read from the data set WORK.DXCCSRDEFT.
 
 258        
 259        DATA DXCCSRDEFT(KEEP=START LABEL FMTNAME TYPE HLO);
 260          SET DXCCSR(KEEP=START I10CCSRDeftOP rename=(I10CCSRDeftOP=LABEL)) END=EOF;
 261        
 262          RETAIN HLO " " FMTNAME "$DXCCSRDOP" TYPE  "J" ;
 263          output;
 264          IF EOF THEN DO ;
 265             START = " " ;
 266             LABEL = " " ;
 267             HLO   = "O";
 268             OUTPUT;
 269          END;
 270        run;
 
 NOTE: There were 73212 observations read from the data set WORK.DXCCSR.
 NOTE: The data set WORK.DXCCSRDEFT has 73213 observations and 5 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.03 seconds
       cpu time            0.03 seconds
       
 
 271        
 272        PROC SORT DATA=DXCCSRDEFT NODUPKEY; BY START; RUN;
 
 NOTE: There were 73213 observations read from the data set WORK.DXCCSRDEFT.
 NOTE: 1 observations with duplicate key values were deleted.
 NOTE: The data set WORK.DXCCSRDEFT has 73212 observations and 5 variables.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           0.02 seconds
       cpu time            0.02 seconds
       
 
 273        
 274        PROC FORMAT LIB=WORK CNTLIN = DXCCSRDEFT;
 NOTE: Informat $DXCCSRDOP is already on the library WORK.FORMATS.
 NOTE: Informat $DXCCSRDOP has been output.
 275        RUN;
 
 NOTE: PROCEDURE FORMAT used (Total process time):
       real time           0.09 seconds
       cpu time            0.09 seconds
       
 NOTE: There were 73212 observations read from the data set WORK.DXCCSRDEFT.
 
 276        
 277        /*********** SECTION 2: CREATE ICD-10-CM CCSR OUTPUT FILES ***********************/
 278        /*  Create CCSR categories for ICD-10-CM using the SAS informats created         */
 279        /*  in Section 1 and the diagnosis codes in your SAS dataset.                    */
 280        /*  At most three separate output files are created plus a few intermediate files*/
 281        /*  for the construction of the horizontal and default DXCCSR for DX1 file       */
 282        /*********************************************************************************/
 283        
 284        %Macro dxccsr_vt(dbt=IP);
 285           DATA &amp;amp;dbt._out_vt (KEEP=&amp;amp;RECID DXCCSR DX_POSITION DEFAULT_DXCCSR DXCCSR_VERSION)
 286                dxccsr_flags  (keep=&amp;amp;RECID flag_anydx flag_xxx flag_dx1)
 287             ;
 288         retain &amp;amp;RECID;
 289             LENGTH ICD10_Code $7 DXCCSR $6 DX_POSITION 3 DEFAULT_DXCCSR $1 DXCCSR_VERSION $6 flag_xxx $6;
 290             LABEL DEFAULT_DXCCSR = "Indication of default CCSR for principal/first-listed ICD-10-CM diagnosis"
 291               DXCCSR = "CCSR category for ICD-10-CM diagnosis"
 292           DX_POSITION = "Position of code in input diagnosis array"
 293           DXCCSR_VERSION = "Version of CCSR for ICD-10-CM diagnoses"
 294           ;
 295        
 296             SET &amp;amp;dbt._in;
 297         by &amp;amp;RECID;
 298             retain DXCCSR_VERSION "2021.2";
 299             array A_DX(&amp;amp;NUMDX)       &amp;amp;DXPREFIX.1-&amp;amp;DXPREFIX.&amp;amp;NUMDX;
 300        
 301             %if &amp;amp;NDXVAR ne %then %let MAXNDX = &amp;amp;NDXVAR;
 302             %else %let MAXNDX=&amp;amp;NUMDX;
 303        
 304             flag_anydx =0; &amp;amp;dbt.flag_xxx=''; flag_dx1=0;
 305         if not missing(&amp;amp;DXPREFIX.1) then flag_dx1=1;
 306        
 307             DO I=1 TO min(&amp;amp;MAXNDX, dim(A_dx));
 308               ICD10_CODE=A_DX(I);
 309               DX_POSITION=I;
 310               Default_DCCSR_Val =input(ICD10_CODE, $DXCCSRD&amp;amp;dbt..);
 311        
 312               if ICD10_CODE ^= '' then flag_anydx=1;
 313        
 314               CCSRString=INPUT(A_DX(I), $DXCCSR.);
 315               if not missing(ICD10_CODE) and missing(CCSRString) then do;
 316              ***invalid diagnosis found;
 317          DXCCSR='InvlDX';
 318          if I= 1 then DEFAULT_DXCCSR = 'X';
 319          else DEFAULT_DXCCSR = '';
 320          output &amp;amp;dbt._out_vt;
 321           end;
 322               else if not missing(CCSRString) then do;
 323                  ccsrn=(COUNTC(CCSRString,'#')+1)/2;
 324              if ccsrn=1 then do;
 325                     next_delim = findc(CCSRString,"#");
 326                 DXCCSR=substr(CCSRString,1, next_delim-1);
 327        
 328                     if I=1 then do;
 329                if Default_DCCSR_Val = DXCCSR then DEFAULT_DXCCSR = 'Y';
 330            else if Default_DCCSR_Val =: 'XXX' then do;
 331                      DEFAULT_DXCCSR = 'X';
 332          flag_xxx=Default_DCCSR_Val;
 333        end;
 334            else DEFAULT_DXCCSR = 'N';
 335         end;
 336         else DEFAULT_DXCCSR = '';
 337        
 338                 output &amp;amp;dbt._out_vt;
 339              end;
 340              else do;
 341               do j=1 to ccsrn;
 342                     next_delim = findc(CCSRString,"#");
 343                     DXCCSR=substr(CCSRString,1, next_delim-1);
 344                     CCSRString=substr(CCSRString,next_delim+1);
 345        
 346                     if I=1 then do;
 347            if Default_DCCSR_Val = DXCCSR then DEFAULT_DXCCSR = 'Y';
 348            else if Default_DCCSR_Val =: 'XXX' then do;
 349          DEFAULT_DXCCSR = 'X';
 350            flag_xxx=Default_DCCSR_Val;
 351        end;
 352            else DEFAULT_DXCCSR = 'N';
 353         end;
 354         else DEFAULT_DXCCSR = '';
 355        
 356                 output &amp;amp;dbt._out_vt;
 357               end;
 358               do j=1 to ccsrn-1;
 359                     next_delim = findc(CCSRString,"#");
 360                 CCSRString=substr(CCSRString,next_delim+1);
 361               end; /*do j*/
 362              end; /*else do*/
 363               end; /*not missing CCSString*/
 364             end; /*loop i*/
 365        
 366         output dxccsr_flags;
 367        run;
 368        
 369        /*If DX1 is missing add it to the vertical file*/
 370        data &amp;amp;dbt._out_vt;
 371          merge &amp;amp;dbt._out_vt(in=inv)
 372                dxccsr_flags(in=inf keep=&amp;amp;RECID flag_dx1)
 373        ;
 374          by &amp;amp;RECID;
 375          if inf and not inv then do;
 376            DXCCSR='NoDX1';
 377            DX_POSITION=1;
 378            DEFAULT_DXCCSR='X';
 379        DXCCSR_VERSION="2021.2";
 380        output;
 381          end;
 382          else if flag_dx1=0 then do;
 383            output;
 384            ***there may be multiple diagnosis on vertical file, output NoDX1 only once;
 385        if first.&amp;amp;RECID then do;
 386              DXCCSR='NoDX1';
 387              DX_POSITION=1;
 388              DEFAULT_DXCCSR='X';
 389          output;
 390        end;
 391          end;
 392          else output;
 393          drop flag_dx1;
 394        run;
 395        
 396        proc sort data=&amp;amp;dbt._out_vt; by &amp;amp;RECID DX_POSITION; run;
 397        
 398        Title1 "Vertical file";
 399        proc contents data=&amp;amp;dbt._out_vt varnum;
 400        run;
 401        Title2 "Sample print of vertical file";
 402        proc print data=&amp;amp;dbt._out_vt (obs=10);
 403        run;
 404        %mend;
 405        
 406        * =========================================================================== *
 407        * Count maximum number of DXCCSR values for each body system.
 408        * Please do not change this code. It is necessary to the program function.
 409        * =========================================================================== *;
 410        %macro count_ccsr;
 411          DATA Body_sys;
 412            length body bnum $3 ;
 413            INFILE INRAW1 DSD DLM=',' END = EOF FIRSTOBS=2;
 414            INPUT
 415               START             : $CHAR7.
 416               I10Label          : $CHAR124.
 417               I10CCSRDeftIP     : $10.
 418               I10CCSRLabelDeftIP: $CHAR228.
 419               I10CCSRDeftOP     : $10.
 420               I10CCSRLabelDeftOP: $CHAR228.
 421               I10CCSR1          : $10.
 422               I10CCSRLabel1     : $CHAR228.
 423               I10CCSR2          : $10.
 424               I10CCSRLabel2     : $CHAR228.
 425               I10CCSR3          : $10.
 426               I10CCSRLabel3     : $CHAR228.
 427               I10CCSR4          : $10.
 428               I10CCSRLabel4     : $CHAR228.
 429               I10CCSR5          : $10.
 430               I10CCSRLabel5     : $CHAR228.
 431               I10CCSR6          : $10.
 432               I10CCSRLabel6     : $CHAR228.
 433            ;
 434        
 435            array ccsrs I10CCSR1-I10CCSR6;
 436            do over ccsrs;
 437              body=substr(ccsrs, 1, 3);
 438              bnum=substr(ccsrs, 4, 3);
 439              if body not in ('', 'XXX')  then output;
 440            end;
 441            keep body bnum;
 442           run;
 443           proc sort data=Body_sys; by body bnum ; run;
 444           data body_max;
 445             set body_sys;
 446             by body bnum;
 447             if last.body;
 448           run;
 449           %global mnbody;
 450           %global body_;
 451           proc sql noprint;
 452             select distinct body into :body_ separated by ' '
 453             from body_max
 454             ;
 455           quit;
 456           data null;
 457             set body_max end=eof;
 458             if eof then call symput("mnbody", put(_N_, 2.));
 459           run;
 460        
 461           %do i=1 %to &amp;amp;mnbody;
 462             %let b=%scan(&amp;amp;body_, &amp;amp;i);
 463             %global max&amp;amp;b. ;
 464           %end;
 465        
 466           data null;
 467             set body_max end=eof;
 468             mbody="max" || body;
 469             call symput(mbody, bnum);
 470             if eof then call symput("mnbody", put(_N_, 2.));
 471           run;
 472        
 473           %put verify macro definition:;
 474           %put mnbody=&amp;amp;mnbody;
 475           %do i=1 %to &amp;amp;mnbody;
 476             %let b=%scan(&amp;amp;body_, &amp;amp;i);
 477             %put max&amp;amp;b._ = &amp;amp;&amp;amp;&amp;amp;max&amp;amp;b;
 478           %end;
 479        %mend;
 480        
 481        %macro dxccsr_hz(dbt=IP);
 482        * =========================================================================== *
 483        * Create horizontal file layout using vertical file                           *
 484        * =========================================================================== *;
 485        Data DXCCSR_First(keep=&amp;amp;RECID DXCCSR) DXCCSR_second(keep=&amp;amp;RECID DXCCSR);
 486          set &amp;amp;dbt._out_vt;
 487          by &amp;amp;RECID;
 488          if DXCCSR not in ('InvlDX', 'NoDX1');
 489          if DX_Position = 1 then output DXCCSR_First;
 490          else output DXCCSR_Second;
 491        run;
 492        
 493        proc sort data=DXCCSR_second nodupkey;
 494          by &amp;amp;RECID DXCCSR;
 495        run;
 496        proc sort data=DXCCSR_First;
 497          by &amp;amp;RECID DXCCSR;
 498        run;
 499        
 500        data DXCCSR;
 501          length DX_Position 3;
 502          merge DXCCSR_First(in=inp) DXCCSR_Second(in=ins);
 503          by &amp;amp;RECID DXCCSR;
 504          if inp and not ins then DX_Position = 1;
 505          else if ins and not inp then DX_Position = 3;
 506          else DX_Position = 2;
 507        run;
 508        
 509        proc transpose data=DXCCSR out=DXCCSR_Transposed(drop=_NAME_) prefix=DXCCSR_;
 510          by &amp;amp;RECID;
 511          ID DXCCSR;
 512          Var DX_Position;
 513        run;
 514        
 515        **** Ensure the horizontal output file has the same number of records as input file;
 516        data &amp;amp;dbt._out_hz ;
 517          retain &amp;amp;RECID;
 518          LENGTH DXCCSR_Default_DX1 $6;
 519          LENGTH
 520            %do i=1 %to &amp;amp;mnbody;
 521              %let b=%scan(&amp;amp;body_, &amp;amp;i);
 522              DXCCSR_&amp;amp;b.001-DXCCSR_&amp;amp;b.&amp;amp;&amp;amp;max&amp;amp;b.
 523            %end;
 524            3 ;
 525          Label
 526            %do i=1 %to &amp;amp;mnbody;
 527              %let b=%scan(&amp;amp;body_, &amp;amp;i);
 528          %do j=1 %to &amp;amp;&amp;amp;max&amp;amp;b.;
 529             %if &amp;amp;j &amp;lt; 10 %then DXCCSR_&amp;amp;b.00&amp;amp;j = "Indication that at least one ICD-10-CM diagnosis on the record is included in
 529      ! CCSR &amp;amp;b.00&amp;amp;j" ;
 530             %else %if &amp;amp;j &amp;lt; 100 %then DXCCSR_&amp;amp;b.0&amp;amp;j = "Indication that at least one ICD-10-CM diagnosis on the record is
 530      ! included in CCSR &amp;amp;b.0&amp;amp;j" ;
 531             %else DXCCSR_&amp;amp;b.&amp;amp;j = "Indication that at least one ICD-10-CM diagnosis on the record is included in CCSR &amp;amp;b.&amp;amp;j" ;
 532          %end;
 533            %end;
 534            ;
 535          merge &amp;amp;dbt._dflt_file(in=ind) DXCCSR_Transposed ;
 536          by &amp;amp;RECID;
 537          if not ind then abort;   ***Should never happen but safe guard, default file contains all records from input file;
 538        
 539          ***If no diagnoses are found on the record, set all DXCCSR_* values to 0;
 540          array a _numeric_;
 541          do over a;
 542            if a = . then a=0;
 543          end;
 544          drop DXCCSR_MBD015 DXCCSR_MBD016;
 545        run;
 546        
 547        Title1 "Horizontal file";
 548        proc contents data=&amp;amp;dbt._out_hz varnum;
 549        run;
 550        Title2 "Sample print of horizontal file";
 551        proc print data=&amp;amp;dbt._out_hz(obs=10);
 552        run;
 553        %mend;
 554        
 555        %macro dxccsr_dflt(dbt=IP);
 556        * ================================================================================= *
 557        * Create the default CCSR file with RECID &amp;amp; Default DXCCSR value using vertical file*
 558        * ================================================================================= *;
 559        data &amp;amp;dbt._dflt_file(keep=&amp;amp;RECID DXCCSR_DEFAULT_DX1);
 560          length DXCCSR_DEFAULT_DX1 $6;
 561          set &amp;amp;dbt._out_vt(keep=&amp;amp;RECID DX_POSITION DXCCSR DEFAULT_DXCCSR);
 562          by &amp;amp;RECID;
 563        
 564          if DX_POSITION = 1 and DEFAULT_DXCCSR in ('Y');
 565          DXCCSR_DEFAULT_DX1 = DXCCSR;
 566        run;
 567        
 568        **** Ensure the default DXCCSR output file has the same number of records as input file;
 569        Data &amp;amp;dbt._dflt_file;
 570          retain &amp;amp;RECID;
 571          length DXCCSR_DEFAULT_DX1 DXCCSR_VERSION $6;
 572          label DXCCSR_DEFAULT_DX1 = "Default CCSR for principal/first-listed ICD-10-CM diagnosis"
 573                DXCCSR_VERSION = "Version of CCSR for ICD-10-CM diagnoses"
 574                ;
 575          merge dxccsr_flags(in=ini)
 576        &amp;amp;dbt._dflt_file(in=ino) ;
 577          by &amp;amp;RECID;
 578          retain DXCCSR_VERSION "2021.2";
 579        
 580          if not ini then abort;
 581          if not ino then do;
 582        if not flag_dx1 then DXCCSR_DEFAULT_DX1 = 'NoDX1';
 583            else if flag_xxx ^='' then DXCCSR_DEFAULT_DX1 = flag_xxx;
 584        else if flag_anydx then DXCCSR_DEFAULT_DX1 = 'InvlDX';
 585          end;
 586          drop flag_anydx flag_xxx flag_dx1;
 587        run;
 588        
 589        %mend;
 590        
 591        %macro main;
 592           %count_ccsr;
 593           proc sort data=IN1.&amp;amp;CORE(obs=&amp;amp;obs_ keep=&amp;amp;RECID &amp;amp;NDXVAR &amp;amp;DXPREFIX.1-&amp;amp;DXPREFIX.&amp;amp;NUMDX %if &amp;amp;dbtype ne and &amp;amp;IOVAR ne %then
 593      !  &amp;amp;IOVAR;) out=&amp;amp;CORE.Skinny; by &amp;amp;RECID;  run;
 594           %if &amp;amp;DBTYPE = IO %then %do;
 595             %if &amp;amp;IOVAR NE %then %do;
 596           data IP_in OP_in NIO;
 597             set &amp;amp;CORE.Skinny;
 598         by &amp;amp;RECID;
 599         if &amp;amp;IOVAR = "&amp;amp;IOValI" then output IP_in;
 600         else if &amp;amp;IOVAR = "&amp;amp;IOValO" then output OP_in;
 601         else output NIO;
 602           run;
 603        
 604               %dxccsr_vt(dbt=IP);
 605               %dxccsr_dflt(dbt=IP);
 606               %dxccsr_vt(dbt=OP);
 607               %dxccsr_dflt(dbt=OP);
 608           %if &amp;amp;vert = 1 %then %do;
 609           data OUT1.&amp;amp;VERTFILE(SortedBy=&amp;amp;RECID);
 610             set IP_out_vt OP_out_vt;
 611             by &amp;amp;RECID;
 612           run;
 613           %end;
 614               %if &amp;amp;dflt = 1 %then %do;
 615                 data OUT1.&amp;amp;DFLTFILE(SortedBy=&amp;amp;RECID);
 616               set IP_dflt_file OP_dflt_file NIO(keep=&amp;amp;RECID);
 617           by &amp;amp;RECID;
 618             run;
 619        
 620                 Title1 "Default DXCCSR file";
 621                 proc contents data=OUT1.&amp;amp;DFLTFILE;
 622                 run;
 623                 Title2 "Sample print of default DXCCSR file";
 624                 proc print data=OUT1.&amp;amp;DFLTFILE(obs=10);
 625                 run;
 626               %end;
 627               %if &amp;amp;horz = 1 %then %do;
 628                 %dxccsr_hz(dbt=IP);
 629                 %dxccsr_hz(dbt=OP);
 630         data out1.&amp;amp;HORZFILE(SortedBy=&amp;amp;RECID);
 631             set IP_out_hz OP_out_hz NIO(keep=&amp;amp;RECID);
 632         by &amp;amp;RECID;
 633           run;
 634        
 635               %end;
 636             %end;
 637             %else ERROR 'IOVAR is not specified';
 638           %end;
 639           %else %if &amp;amp;DBTYPE = IP %then %do;
 640             data IP_in;
 641             set &amp;amp;CORE.Skinny;
 642         by &amp;amp;RECID;
 643             run;
 644        
 645             %dxccsr_vt(dbt=IP);
 646             %if &amp;amp;vert = 1 %then %do;
 647         data OUT1.&amp;amp;VERTFILE(SortedBy=&amp;amp;RECID);
 648           set IP_out_vt;
 649           by &amp;amp;RECID;
 650         run;
 651         %end;
 652             %dxccsr_dflt(dbt=IP);
 653             %if &amp;amp;dflt = 1 %then %do;
 654               data OUT1.&amp;amp;DFLTFILE(SortedBy=&amp;amp;RECID);
 655             set IP_dflt_file;
 656         by &amp;amp;RECID;
 657           run;
 658        
 659               Title1 "Default DXCCSR file";
 660               proc contents data=OUT1.&amp;amp;DFLTFILE;
 661               run;
 662               Title2 "Sample print of default DXCCSR file";
 663               proc print data=OUT1.&amp;amp;DFLTFILE(obs=10);
 664               run;
 665             %end;
 666             %if &amp;amp;horz = 1 %then %do;
 667               %dxccsr_hz(dbt=IP);
 668              data out1.&amp;amp;HORZFILE(SortedBy=&amp;amp;RECID);
 669             set IP_out_hz;
 670         by &amp;amp;RECID;
 671           run;
 672             %end;
 673           %end;
 674           %else %if &amp;amp;DBTYPE = OP %then %do;
 675             data OP_in;
 676             set &amp;amp;CORE.Skinny;
 677         by &amp;amp;RECID;
 678             run;
 679        
 680             %dxccsr_vt(dbt=OP);
 681             %if &amp;amp;vert = 1 %then %do;
 682         data OUT1.&amp;amp;VERTFILE(SortedBy=&amp;amp;RECID);
 683           set OP_out_vt;
 684           by &amp;amp;RECID;
 685         run;
 686         %end;
 687             %dxccsr_dflt(dbt=OP);
 688             %if &amp;amp;dflt = 1 %then %do;
 689               data OUT1.&amp;amp;DFLTFILE(SortedBy=&amp;amp;RECID);
 690             set OP_dflt_file;
 691         by &amp;amp;RECID;
 692           run;
 693        
 694               Title1 "Default DXCCSR file";
 695               proc contents data=OUT1.&amp;amp;DFLTFILE;
 696               run;
 697               Title2 "Sample print of default DXCCSR file";
 698               proc print data=OUT1.&amp;amp;DFLTFILE(obs=10);
 699               run;
 700             %end;
 701             %if &amp;amp;horz = 1 %then %do;
 702               %dxccsr_hz(dbt=OP);
 703              data out1.&amp;amp;HORZFILE(SortedBy=&amp;amp;RECID);
 704             set OP_out_hz;
 705         by &amp;amp;RECID;
 706           run;
 707             %end;
 708           %end;
 709        
 710        %mend;
 711        %main;
 
 NOTE: The infile INRAW1 is:
       Filename=/folders/myfolders/HCUP/NIS2018/DXCCSR_v2021-2.csv,
       Owner Name=root,Group Name=vboxsf,
       Access Permission=-rwxrwx---,
       Last Modified=04 March 2021 11:01:46,
       File Size (bytes)=20053092
 
 NOTE: 73211 records were read from the infile INRAW1.
       The minimum record length was 93.
       The maximum record length was 594.
 NOTE: The data set WORK.BODY_SYS has 83464 observations and 2 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.16 seconds
       cpu time            0.15 seconds
       
 
 
 NOTE: There were 83464 observations read from the data set WORK.BODY_SYS.
 NOTE: The data set WORK.BODY_SYS has 83464 observations and 2 variables.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           0.02 seconds
       cpu time            0.03 seconds
       
 
 
 NOTE: There were 83464 observations read from the data set WORK.BODY_SYS.
 NOTE: The data set WORK.BODY_MAX has 21 observations and 2 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 NOTE: PROCEDURE SQL used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 
 NOTE: There were 21 observations read from the data set WORK.BODY_MAX.
 NOTE: The data set WORK.NULL has 21 observations and 2 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 
 NOTE: There were 21 observations read from the data set WORK.BODY_MAX.
 NOTE: The data set WORK.NULL has 21 observations and 3 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 verify macro definition:
 mnbody=21
 maxBLD_ = 010
 maxCIR_ = 039
 maxDIG_ = 025
 maxEAR_ = 006
 maxEND_ = 017
 maxEXT_ = 030
 maxEYE_ = 012
 maxFAC_ = 025
 maxGEN_ = 026
 maxINF_ = 012
 maxINJ_ = 076
 maxMAL_ = 010
 maxMBD_ = 034
 maxMUS_ = 038
 maxNEO_ = 074
 maxNVS_ = 022
 maxPNL_ = 015
 maxPRG_ = 030
 maxRSP_ = 017
 maxSKN_ = 007
 maxSYM_ = 017
 ERROR: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.
 ERROR: The variable DBTYPE in the DROP, KEEP, or RENAME list has never been referenced.
 
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.NIS_2018_CORESKINNY may be incomplete.  When this step was stopped there were 0 observations and 0 
          variables.
 WARNING: Data set WORK.NIS_2018_CORESKINNY was not replaced because this step was stopped.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           0.01 seconds
       cpu time            0.02 seconds
       
 
 
 
 ERROR: BY variable KEY is not on input data set WORK.NIS_2018_CORESKINNY.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.IP_IN may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
 WARNING: Data set WORK.IP_IN was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 
 
 NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
       711:160   711:74    
 NOTE: Variable KEY is uninitialized.
 NOTE: Variable I10_NDX is uninitialized.
 ERROR: BY variable KEY is not on input data set WORK.IP_IN.
 WARNING: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.
 WARNING: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.IP_OUT_VT may be incomplete.  When this step was stopped there were 0 observations and 4 variables.
 WARNING: Data set WORK.IP_OUT_VT was not replaced because this step was stopped.
 WARNING: The data set WORK.DXCCSR_FLAGS may be incomplete.  When this step was stopped there were 0 observations and 3 variables.
 WARNING: Data set WORK.DXCCSR_FLAGS was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.03 seconds
       cpu time            0.02 seconds
       
 
 
 ERROR: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.
 
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.IP_OUT_VT may be incomplete.  When this step was stopped there were 0 observations and 4 variables.
 WARNING: Data set WORK.IP_OUT_VT was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 
 ERROR: Variable KEY not found.
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE SORT used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 
 NOTE: PROCEDURE CONTENTS used (Total process time):
       real time           0.05 seconds
       cpu time            0.04 seconds
       
 
 
 NOTE: No observations in data set WORK.IP_OUT_VT.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 
 ERROR: BY variable KEY is not on input data set WORK.IP_OUT_VT.
 ERROR: Variable KEY not found.
 ERROR: Invalid value for the SORTEDBY option.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set OUT1.NIS_CORE_OUTPUT_VERT may be incomplete.  When this step was stopped there were 0 observations and 0 
          variables.
 WARNING: Data set OUT1.NIS_CORE_OUTPUT_VERT was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.01 seconds
       cpu time            0.00 seconds
       
 
 ERROR: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.
 
 WARNING: The variable KEY in the DROP, KEEP, or RENAME list has never been referenced.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.IP_DFLT_FILE may be incomplete.  When this step was stopped there were 0 observations and 1 variables.
 WARNING: Data set WORK.IP_DFLT_FILE was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 
 
 NOTE: Variable KEY is uninitialized.
 ERROR: BY variable KEY is not on input data set WORK.DXCCSR_FLAGS.
 ERROR: BY variable KEY is not on input data set WORK.IP_DFLT_FILE.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.IP_DFLT_FILE may be incomplete.  When this step was stopped there were 0 observations and 2 variables.
 WARNING: Data set WORK.IP_DFLT_FILE was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.01 seconds
       
 
 712        
 713        
 714        
 715        OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 727        &lt;/PRE&gt;&lt;P&gt;This is the error message I get&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 01:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738065#M9949</guid>
      <dc:creator>ededeStats</dc:creator>
      <dc:date>2021-04-30T01:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: Running SAS Program to Add CCSR Categories to NIS Data</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738086#M9950</link>
      <description>&lt;P&gt;Check if the variables KEY and DBTYPE are present in the dataset named IN1.NIS_2018_CORE.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 03:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738086#M9950</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-30T03:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Running SAS Program to Add CCSR Categories to NIS Data</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738088#M9951</link>
      <description>&lt;P&gt;The 'IN1.NIS_2018_Core' dataset has 'KEY_NIS' as the identifier not 'KEY.' However, the load program for DXCCSR ICD-10 has KEY, which is very odd. DBTYPE is not present.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 03:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738088#M9951</guid>
      <dc:creator>ededeStats</dc:creator>
      <dc:date>2021-04-30T03:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Running SAS Program to Add CCSR Categories to NIS Data</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738089#M9952</link>
      <description>&lt;P&gt;For IN1.&amp;amp;CORE in this proc Step, the variables KEY (macro variable: &amp;amp;RECID) and DBTYPE (macro variable: IOVAR) are specified in the keep=dataset option, so it is not processed correctly.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=IN1.&amp;amp;CORE(obs=&amp;amp;obs_ keep=&amp;amp;RECID &amp;amp;NDXVAR &amp;amp;DXPREFIX.1-&amp;amp;DXPREFIX.&amp;amp;NUMDX %if &amp;amp;dbtype ne and &amp;amp;IOVAR ne %then  &amp;amp;IOVAR;) out=&amp;amp;CORE.Skinny; by &amp;amp;RECID;  run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't know if the problem is with the original data, the program, or the macro variable specification.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 03:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Running-SAS-Program-to-Add-CCSR-Categories-to-NIS-Data/m-p/738089#M9952</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-30T03:39:02Z</dc:date>
    </item>
  </channel>
</rss>

