<?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 Proc Transpose to avoid ID variable occurring twice in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-Proc-Transpose-to-avoid-ID-variable-occurring-twice/m-p/765940#M242669</link>
    <description>&lt;P&gt;First of all, by using month&amp;nbsp;&lt;EM&gt;names&lt;/EM&gt;, you will never get a chronological order, because August comes before any month not beginning with A (lexically). Convert your month/year first to something that sorts, like 2021-08 for August 2021. As it is &lt;STRONG&gt;ALWAYS&lt;/STRONG&gt; better to store dates or date-related values as SAS dates, and assign appropriate formats (YYMMD7. will display the date 2021-08-01 as 2021-08, and TRANSPOSE will use the formatted value).&lt;/P&gt;
&lt;P&gt;And next, add jurisdiction as a BY variable to avoid the duplicates.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Sep 2021 21:24:01 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-09-03T21:24:01Z</dc:date>
    <item>
      <title>Creating Proc Transpose to avoid ID variable occurring twice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Proc-Transpose-to-avoid-ID-variable-occurring-twice/m-p/765936#M242667</link>
      <description>&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;I have included a small sample of data that I would like to transpose.&amp;nbsp; The following log contains the 20 obs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: The infile _CODE_ is:
      Filename=D:\Data\OR0206965\SASWORK\_TD51864_WPOHAAPPL87_\#LN00417,
      RECFM=V,LRECL=32767,File Size (bytes)=1541,
      Last Modified=03Sep2021:14:02:18,
      Create Time=03Sep2021:14:02:18

data work.Arias_CBOs_with_Contacts_3 ;
  infile datalines dsd dlm='|' truncover;
  input CBO :$44. Jurisdiction :$14. Tracers Contacts Month :$14.
    Year :$14.
  ;
  format CBO $44. Jurisdiction $14. Tracers best. Contacts best. ;
  informat CBO $44. Jurisdiction $14. ;
  label CBO='CBO' Jurisdiction='Jurisdiction' Tracers='Tracers'
    Contacts='Contacts'
  ;
datalines4;
COFA Alliance National Network (CANN)|Marion CHD|1|1|JULY|2021
COFA Alliance National Network (CANN)|Union CHD|1|4|OCTOBER|2020
COFA Alliance National Network (CANN)|Union CHD|3|48|NOVEMBER|2020
COFA Alliance National Network (CANN)|Union CHD|1|1|JANUARY|2021
COFA Alliance National Network (CANN)|Union CHD|5|15|FEBRUARY|2021
Centro Latino Americano|Lane CHD|1|3|AUGUST|2020
Centro Latino Americano|Lane CHD|2|13|SEPTEMBER|2020
Centro Latino Americano|Lane CHD|2|8|OCTOBER|2020
Centro Latino Americano|Lane CHD|2|26|NOVEMBER|2020
Centro Latino Americano|Lane CHD|2|3|DECEMBER|2020
Centro Latino Americano|Lane CHD|1|3|JANUARY|2021
Centro Latino Americano|Lane CHD|1|1|MARCH|2021
Columbia Gorge Health Council|Hood River CHD|1|8|JANUARY|2021
Columbia Gorge Health Council|Hood River CHD|1|7|FEBRUARY|2021
Cornerstone Associates, Inc|Benton CHD|1|1|MARCH|2021
Cornerstone Associates, Inc|Benton CHD|1|2|JUNE|2021
Cornerstone Associates, Inc|Benton CHD|2|2|JULY|2021
Cornerstone Associates, Inc|Linn CHD|2|14|FEBRUARY|2021
Cornerstone Associates, Inc|Linn CHD|2|25|MARCH|2021
Cornerstone Associates, Inc|Linn CHD|2|11|APRIL|2021
;;;;
NOTE: 32 records were read from the infile _CODE_.
      The minimum record length was 3.
      The maximum record length was 66.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: Fileref _CODE_ has been deassigned.

NOTE: Deleting WORK._DS2POST_ (memtype=DATA).
NOTE: PROCEDURE DELETE used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds



&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I ran some code to create a transposed dataset like this (that I saw in a Mike Zdeb article):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CBO&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jurisdiction&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _NAME_&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; June2020 .............. June2021&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Tracers&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Contacts&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code follows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort Data = SASCDC_2.Arias_CBOs_with_Contacts_3;
by CBO;
run;

proc transpose data = SASCDC_2.Arias_CBOs_with_Contacts_3 out = SASCDC_2.Arias_Transpose_CBOs;                     
by CBO;
Var Tracers Contacts;
id Month Year;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The problem is shown in the log.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; proc transpose data = SASCDC_2.Arias_CBOs_with_Contacts_3 out = SASCDC_2.Arias_Transpose_CBOs;
774  by CBO;
775  Var Tracers Contacts;
776  id Month Year;
777  run;

ERROR: The ID value "MARCH2021" occurs twice in the same BY group.
ERROR: The ID value "JULY2021" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
      CBO=Cornerstone Associates, Inc
ERROR: The ID value "JANUARY2021" occurs twice in the same BY group.
ERROR: The ID value "DECEMBER2020" occurs twice in the same BY group.
ERROR: The ID value "JANUARY2021" occurs twice in the same BY group.
ERROR: The ID value "FEBRUARY2021" occurs twice in the same BY group.
ERROR: The ID value "APRIL2021" occurs twice in the same BY group.
ERROR: The ID value "JULY2021" occurs twice in the same BY group.
ERROR: The ID value "AUGUST2021" occurs twice in the same BY group.
ERROR: The ID value "OCTOBER2020" occurs twice in the same BY group.
ERROR: The ID value "NOVEMBER2020" occurs twice in the same BY group.
ERROR: The ID value "JANUARY2021" occurs twice in the same BY group.
ERROR: The ID value "FEBRUARY2021" occurs twice in the same BY group.
ERROR: The ID value "MARCH2021" occurs twice in the same BY group.
ERROR: The ID value "APRIL2021" occurs twice in the same BY group.
ERROR: The ID value "AUGUST2021" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
      CBO=Eastern Oregon Center For Independent Living
ERROR: The ID value "DECEMBER2020" occurs twice in the same BY group.
ERROR: The ID value "JANUARY2021" occurs twice in the same BY group.
ERROR: The ID value "DECEMBER2020" occurs twice in the same BY group.
ERROR: The ID value "JANUARY2021" occurs twice in the same BY group.
ERROR: The ID value "FEBRUARY2021" occurs twice in the same BY group.
ERROR: The ID value "MARCH2021" occurs twice in the same BY group.
ERROR: The ID value "APRIL2021" occurs twice in the same BY group.
ERROR: The ID value "MAY2021" occurs twice in the same BY group.
ERROR: The ID value "AUGUST2021" occurs twice in the same BY group.
ERROR: The ID value "NOVEMBER2020" occurs twice in the same BY group.
ERROR: The ID value "JANUARY2021" occurs twice in the same BY group.
ERROR: The ID value "FEBRUARY2021" occurs twice in the same BY group.
ERROR: The ID value "MARCH2021" occurs twice in the same BY group.
ERROR: The ID value "APRIL2021" occurs twice in the same BY group.
ERROR: The ID value "JULY2021" occurs twice in the same BY group.
ERROR: The ID value "AUGUST2021" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
      CBO=Euvalcree
ERROR: The ID value "JANUARY2021" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
      CBO=La Clinica
ERROR: The ID value "NOVEMBER2020" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
      CBO=Latino Community Association
ERROR: The ID value "JUNE2020" occurs twice in the same BY group.
ERROR: The ID value "JULY2020" occurs twice in the same BY group.
ERROR: The ID value "NOVEMBER2020" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
      CBO=Northwest Family Services
ERROR: The ID value "AUGUST2020" occurs twice in the same BY group.
ERROR: The ID value "SEPTEMBER2020" occurs twice in the same BY group.
ERROR: The ID value "OCTOBER2020" occurs twice in the same BY group.
ERROR: The ID value "NOVEMBER2020" occurs twice in the same BY group.
ERROR: The ID value "JULY2020" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
      CBO=Olalla Center
WARNING: 7 BY groups omitted due to earlier errors.
NOTE: There were 152 observations read from the data set SASCDC_2.ARIAS_CBOS_WITH_CONTACTS_3.
NOTE: The data set SASCDC_2.ARIAS_TRANSPOSE_CBOS has 16 observations and 18 variables.
NOTE: Compressing data set SASCDC_2.ARIAS_TRANSPOSE_CBOS increased size by 100.00 percent.
      Compressed is 2 pages; un-compressed would require 1 pages.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And also the monthyear&amp;nbsp; in the header row do not following chronologically.&amp;nbsp; For instance,&amp;nbsp; it can be&amp;nbsp; August2020&amp;nbsp;&amp;nbsp;&amp;nbsp; May2021&amp;nbsp;&amp;nbsp;&amp;nbsp; etc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your help is appreciated, thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;wklierman&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 21:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Proc-Transpose-to-avoid-ID-variable-occurring-twice/m-p/765936#M242667</guid>
      <dc:creator>wlierman</dc:creator>
      <dc:date>2021-09-03T21:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Proc Transpose to avoid ID variable occurring twice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Proc-Transpose-to-avoid-ID-variable-occurring-twice/m-p/765937#M242668</link>
      <description>should be  August2021     May2020   February2021     etc</description>
      <pubDate>Fri, 03 Sep 2021 21:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Proc-Transpose-to-avoid-ID-variable-occurring-twice/m-p/765937#M242668</guid>
      <dc:creator>wlierman</dc:creator>
      <dc:date>2021-09-03T21:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Proc Transpose to avoid ID variable occurring twice</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-Proc-Transpose-to-avoid-ID-variable-occurring-twice/m-p/765940#M242669</link>
      <description>&lt;P&gt;First of all, by using month&amp;nbsp;&lt;EM&gt;names&lt;/EM&gt;, you will never get a chronological order, because August comes before any month not beginning with A (lexically). Convert your month/year first to something that sorts, like 2021-08 for August 2021. As it is &lt;STRONG&gt;ALWAYS&lt;/STRONG&gt; better to store dates or date-related values as SAS dates, and assign appropriate formats (YYMMD7. will display the date 2021-08-01 as 2021-08, and TRANSPOSE will use the formatted value).&lt;/P&gt;
&lt;P&gt;And next, add jurisdiction as a BY variable to avoid the duplicates.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 21:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-Proc-Transpose-to-avoid-ID-variable-occurring-twice/m-p/765940#M242669</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-03T21:24:01Z</dc:date>
    </item>
  </channel>
</rss>

