<?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: Proc TRANSPOSE truncs values of the ID statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-TRANSPOSE-truncs-values-of-the-ID-statement/m-p/386365#M92517</link>
    <description>&lt;P&gt;Use a varaible with shorter values for the ID variable and use the existing one for the IDLABEL variable instead. &amp;nbsp;If you do not have another variable you can use then make one. &amp;nbsp;Here is a method to just number the distinct values found.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  length NUMERO_CASO $15 DESCRIZIONE_SERVIZIO $50 COUNT_SERV 8;
  infile cards dsd dlm='|' truncover ;
  input NUMERO_CASO DESCRIZIONE_SERVIZIO COUNT_SERV ;
cards;
1-1107594808|ESTRATTO PAGAMENTI SENZA PIN|1
1-1107594808|PENSIONI - DETTAGLIO RATA PAGAMENTO CON PIN|7
1-1107594808|PENSIONI - DETTAGLIO RATA PAGAMENTO SENZA PIN|4
1-1107594808|PIN INPS - GESTIONE RICHIESTE|3
1-1107594808|STATO DOMANDA|2
1-1107594808|VISUALIZZAZIONE CORRISPONDENZA INPS|5
;
proc sql ;
  create table fmt as
  select distinct DESCRIZIONE_SERVIZIO as START
  from have
  ;
quit;
data fmt;
  fmtname='id';
  type='i';
  label+1;
  set fmt;
run;

proc format cntlin=fmt fmtlib;
run;

data step1;
  set have;
  id = input(DESCRIZIONE_SERVIZIO,id.);
run;

proc transpose data=step1 prefix=SERV out=want(drop=_name_) ;
  by NUMERO_CASO;
  id id;
  idlabel DESCRIZIONE_SERVIZIO;
  var COUNT_SERV;
run;

proc print data=want ; 
run;

proc print data=want label; 
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14380iF834D12C794E2883/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Aug 2017 18:47:20 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-08-08T18:47:20Z</dc:date>
    <item>
      <title>Proc TRANSPOSE truncs values of the ID statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-TRANSPOSE-truncs-values-of-the-ID-statement/m-p/386325#M92499</link>
      <description>&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm using the proc transpose but it seems &amp;nbsp;truncs some of the values of the ID statement.&lt;/P&gt;&lt;P&gt;A piece of the table is:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;NUMERO_CASO&lt;/TD&gt;&lt;TD&gt;DESCRIZIONE_SERVIZIO&lt;/TD&gt;&lt;TD&gt;COUNT_SERV&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1-1107594808&lt;/TD&gt;&lt;TD&gt;ESTRATTO PAGAMENTI SENZA PIN&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1-1107594808&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;PENSIONI - DETTAGLIO RATA PAGAMENTO CON PIN&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1-1107594808&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;PENSIONI - DETTAGLIO RATA PAGAMENTO SENZA PIN&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1-1107594808&lt;/TD&gt;&lt;TD&gt;PIN INPS - GESTIONE RICHIESTE&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1-1107594808&lt;/TD&gt;&lt;TD&gt;STATO DOMANDA&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1-1107594808&lt;/TD&gt;&lt;TD&gt;VISUALIZZAZIONE CORRISPONDENZA INPS&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the code i'm using is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;proc transpose data=from out=want ;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;by numero_caso;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;var count_serv;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;id descrizione_servizio;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the error is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;ERROR: The ID value "'PENSIONI - DETTAGLIO RATA PAGAME'n" occurs twice in the same BY group.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you see the value is has been truncated so the second and the third rows result equal to each other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can i solve this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 16:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-TRANSPOSE-truncs-values-of-the-ID-statement/m-p/386325#M92499</guid>
      <dc:creator>gabras</dc:creator>
      <dc:date>2017-08-08T16:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc TRANSPOSE truncs values of the ID statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-TRANSPOSE-truncs-values-of-the-ID-statement/m-p/386328#M92501</link>
      <description>&lt;P&gt;SAS has a limit of 32 characters for a variable name. Discounting the quotes for the name literal the ID variable is truncated to 32 characters.&lt;/P&gt;
&lt;P&gt;You might consider changing the values of the variable to something shorter and then assigning labels to get the longer text to appear form most procedures in output or table views.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally I hate trying to type variables longer than about 12 characters and seldom use them and basically never use name literal variables.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 16:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-TRANSPOSE-truncs-values-of-the-ID-statement/m-p/386328#M92501</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-08T16:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc TRANSPOSE truncs values of the ID statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-TRANSPOSE-truncs-values-of-the-ID-statement/m-p/386365#M92517</link>
      <description>&lt;P&gt;Use a varaible with shorter values for the ID variable and use the existing one for the IDLABEL variable instead. &amp;nbsp;If you do not have another variable you can use then make one. &amp;nbsp;Here is a method to just number the distinct values found.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  length NUMERO_CASO $15 DESCRIZIONE_SERVIZIO $50 COUNT_SERV 8;
  infile cards dsd dlm='|' truncover ;
  input NUMERO_CASO DESCRIZIONE_SERVIZIO COUNT_SERV ;
cards;
1-1107594808|ESTRATTO PAGAMENTI SENZA PIN|1
1-1107594808|PENSIONI - DETTAGLIO RATA PAGAMENTO CON PIN|7
1-1107594808|PENSIONI - DETTAGLIO RATA PAGAMENTO SENZA PIN|4
1-1107594808|PIN INPS - GESTIONE RICHIESTE|3
1-1107594808|STATO DOMANDA|2
1-1107594808|VISUALIZZAZIONE CORRISPONDENZA INPS|5
;
proc sql ;
  create table fmt as
  select distinct DESCRIZIONE_SERVIZIO as START
  from have
  ;
quit;
data fmt;
  fmtname='id';
  type='i';
  label+1;
  set fmt;
run;

proc format cntlin=fmt fmtlib;
run;

data step1;
  set have;
  id = input(DESCRIZIONE_SERVIZIO,id.);
run;

proc transpose data=step1 prefix=SERV out=want(drop=_name_) ;
  by NUMERO_CASO;
  id id;
  idlabel DESCRIZIONE_SERVIZIO;
  var COUNT_SERV;
run;

proc print data=want ; 
run;

proc print data=want label; 
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14380iF834D12C794E2883/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2017 18:47:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-TRANSPOSE-truncs-values-of-the-ID-statement/m-p/386365#M92517</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-08T18:47:20Z</dc:date>
    </item>
  </channel>
</rss>

