<?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: How to solve for proc transpose error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/857065#M338607</link>
    <description>&lt;P&gt;you are correct, I just made that adjustment and it gave me what I needed.&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;</description>
    <pubDate>Fri, 03 Feb 2023 15:26:44 GMT</pubDate>
    <dc:creator>LMSSAS</dc:creator>
    <dc:date>2023-02-03T15:26:44Z</dc:date>
    <item>
      <title>How to solve for proc transpose error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/856962#M338579</link>
      <description>&lt;P&gt;I am trying to solve for an error that I am getting from proc transpose. "ERROR: The ID value "'2023'"n occurs twice in the same BY group."&amp;nbsp; Below is the table I am trying to create in SAS. Below the table visual is the data Output from SAS, and then my code and log code. Can anyone offer suggestions on how to get the desired outcome. I am using a macro that will loop through the Code column in the output data and pull the values for each class code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LMSSAS_3-1675374533209.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80063i70693DABB705B6AA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LMSSAS_3-1675374533209.png" alt="LMSSAS_3-1675374533209.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LMSSAS_2-1675374512431.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80062i09334CF7B3DAE5B3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LMSSAS_2-1675374512431.png" alt="LMSSAS_2-1675374512431.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; create table SalesbyEP_Year as
Select distinct * From  
(SELECT DISTINCT * FROM SalesTable_2023PY
UNION ALL 
SELECT DISTINCT * FROM SalesTable_2023CY)
group by Enrollment_Period, Year, Active_policies
;QUIT;

PROC TRANSPOSE DATA = SalesbyEP_Year OUT= OUTPUT (drop=_name_);
BY  Enrollment_period ;
ID  Year;

The SAS System

10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGHTML TEMP;
15         ODS HTML(ID=EGHTML) FILE=EGHTML
16             ENCODING='utf-8'
17             STYLE=HTMLBlue
18             STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
19             NOGTITLE
20             NOGFOOTNOTE
21             GPATH=&amp;amp;sasworklocation
22         ;
NOTE: Writing HTML(EGHTML) Body file: EGHTML
23         FILENAME EGSR TEMP;
24         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
25             STYLE=HTMLBlue
26             STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
27             NOGTITLE
28             NOGFOOTNOTE
29             GPATH=&amp;amp;sasworklocation
30             ENCODING=UTF8
31             options(rolap="on")
32         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
33         
34         GOPTIONS ACCESSIBLE;
35         PROC TRANSPOSE DATA = SalesbyEP_Year OUT= OUTPUT (drop=_name_);
36         BY  Enrollment_period ;
37         ID  Year;
38         var Active_policies
39         ;RUN;

ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
The SAS System

ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
      Enrollment_Period=AEP
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
      Enrollment_Period=LockIn
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2022'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
The SAS System

ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
ERROR: The ID value "'2023'n" occurs twice in the same BY group.
NOTE: The above message was for the following BY group:
      Enrollment_Period=OEP
ERROR: All BY groups were bad.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 83 observations read from the data set WORK.SALESBYEP_YEAR.
WARNING: The data set WORK.OUTPUT may be incomplete.  When this step was stopped there were 0 observations and 0 variables.
WARNING: Data set WORK.OUTPUT was not replaced because this step was stopped.
NOTE: PROCEDURE TRANSPOSE used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
40         
41         GOPTIONS NOACCESSIBLE;
42         %LET _CLIENTTASKLABEL=;
43         %LET _CLIENTPROCESSFLOWNAME=;
44         %LET _CLIENTPROJECTPATH=;
45         %LET _CLIENTPROJECTPATHHOST=;
46         %LET _CLIENTPROJECTNAME=;
47         %LET _SASPROGRAMFILE=;
48         %LET _SASPROGRAMFILEHOST=;
49         
50         ;*';*";*/;quit;run;
51         ODS _ALL_ CLOSE;
52         
53         
54         QUIT; RUN;
55         

var Active_policies
;RUN; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Feb 2023 21:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/856962#M338579</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2023-02-02T21:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve for proc transpose error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/856963#M338580</link>
      <description>&lt;P&gt;Two questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What about the CODE variable in the photograph you posted of the data? Should that be part of the BY group for the proc transpose?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What type of variable is YEAR?&amp;nbsp; Is it numeric or character?&amp;nbsp; If numeric what display format does it have a attached?&amp;nbsp; If YEAR is a date value with the YEAR format attached then two different dates like '01JAN2022'd and '01FEB2022'd will both try to create the same variable named '2022'n .&amp;nbsp; And if year is a character variable then two different values like '2022' and '&amp;nbsp; &amp;nbsp;2022' will both try to create the same variable named '2022'n.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2023 22:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/856963#M338580</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-02-02T22:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve for proc transpose error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/856997#M338590</link>
      <description>&lt;P&gt;What you want is not a dataset, but a report.&lt;/P&gt;
&lt;P&gt;Use enrollment_period as group, year as an across variable, and sales as analysis with sum.&lt;/P&gt;
&lt;P&gt;Something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=have;
column ("Total Sales" enrollment_period sales,year);
define enrollment_period / "Product" group;
define sales / "" analysis sum;
define year / "" across;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested; for tested code, supply example data in a data step with datalines, so we can recreate your dataset with a simple copy/paste and submit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: added column-spanning header&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 09:02:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/856997#M338590</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-03T09:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve for proc transpose error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/857035#M338601</link>
      <description>&lt;P&gt;Thank you, Tom&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;SPAN&gt;CODE variable in the photograph I posted of the data is not going to be included in the report, instead I am going to use a macro and loop through each code attribute for a seperate report for each one. I appreciate the info on the date's and will double check the values on those and&amp;nbsp; use for future trobleshooting. I used the proc report code you provided and it gets me a lot closer to what I'm look for and it's so much easier. I didn't realize i could skip proc transpose and do everything in proc report. Below is your code and the report I have when I ran it . I want the analysis sum to calulate under the year columns rather than it's own Sales column. Can you tell me how to get the analysis sum under the years?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LMSSAS_0-1675431733780.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80075iE77F3DF5021DF784/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LMSSAS_0-1675431733780.png" alt="LMSSAS_0-1675431733780.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cols ("Total Sales" enrollment_period sales year); 
	define Enrollment_Period / "Product" group /*style=[cellwidth=1.4in]
	style(column)=[font=("Arial", 8.0pt)]*/ ;
	define Year / "Year" across /*style=[cellwidth=1.4in]
	style(column)=[font=("Arial", 8.0pt)]*/ ;
	define Sales / "Sales" analysis sum /*style=[cellwidth=1.4in]
	style(column)=[font=("Arial", 8.0pt)]*/ ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 13:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/857035#M338601</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2023-02-03T13:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve for proc transpose error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/857047#M338603</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Kurt - I used the proc report code you provided and it gets me a lot closer to what I'm look for and it's so much easier. I didn't realize i could skip proc transpose and do everything in proc report. Below is your code and the report I have when I ran it . I want the analysis sum to calulate under the year columns rather than it's own Sales column. Can you tell me how to get the analysis sum under the years?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LMSSAS_0-1675432924044.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80082i1F44C8900454A927/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LMSSAS_0-1675432924044.png" alt="LMSSAS_0-1675432924044.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report data=SalesbyEP_Year  nowd split='|' spanrows
style(header) = [font=("Arial",9.0pt)
vjust=middle just=center background=%RGB(0,145,204) foreground=whitesmoke font_weight=bold cellwidth=1in];
    cols ("Total Sales" enrollment_period sales year); 
	define Enrollment_Period / "Product" group /*style=[cellwidth=1.4in]
	style(column)=[font=("Arial", 8.0pt)]*/ ;
	define Year / "Year" across /*style=[cellwidth=1.4in]
	style(column)=[font=("Arial", 8.0pt)]*/ ;
	define Sales / "Sales" analysis sum /*style=[cellwidth=1.4in]
	style(column)=[font=("Arial", 8.0pt)]*/ ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Feb 2023 14:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/857047#M338603</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2023-02-03T14:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve for proc transpose error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/857063#M338606</link>
      <description>&lt;P&gt;When programming, details are&amp;nbsp;&lt;U&gt;extremely&lt;/U&gt; important. Your COLUMNS statement misses a crucial comma.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 15:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/857063#M338606</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-03T15:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to solve for proc transpose error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/857065#M338607</link>
      <description>&lt;P&gt;you are correct, I just made that adjustment and it gave me what I needed.&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 15:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-solve-for-proc-transpose-error/m-p/857065#M338607</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2023-02-03T15:26:44Z</dc:date>
    </item>
  </channel>
</rss>

