<?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: transpose truncating var values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/transpose-truncating-var-values/m-p/716299#M221349</link>
    <description>&lt;P&gt;The ID statement in PROC TRANSPOSE lets you tell it what variable to use to NAME the variables it creates.&amp;nbsp; Variables in SAS can only by up to 32 characters long.&lt;/P&gt;
&lt;P&gt;If you want to attach those long descriptive text strings to the variables use the IDLABEL statement in PROC TRANSPOSE to use those strings as the LABEL to be attached to the variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
  infile datalines delimiter=',';
  length person_id $8 ques_txt $200 response $30 uniqueid 8;
  input ques_txt person_id response uniqueid;
datalines;
This question is nonsense about how long the question is,22,No,1
This question is more nonsense about nothing,22,Yes,2
This question is still more nonsense,22,Maybe,3
This question is nonsense about how long the question is,65,Yes,4
This question is more nonsense about nothing,65,Who knows,5
This question is still more nonsense,65,Si,6
This question is nonsense about how long the question is,44,No,7
This question is more nonsense about nothing,44,Yes,8
This question is still more nonsense,44,Not on your life,9
;
proc sort data=test1;
  by ques_txt;
run;

data test2 ;
  set test1;
  by ques_txt;
  ques_num + first.ques_txt;
run;

proc sort data=test2 nodupkey out=test3;
  by person_id ques_num;
run;

proc transpose data=test3 prefix=ques out=test4 (drop=_name_ _label_);
  by person_id ;
  id ques_num;
  idlabel ques_txt;
  var response;
run;

proc print data=test4;
run;
proc print data=test4 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: 603px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54254iD79875D0DA1FB273/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>Wed, 03 Feb 2021 03:40:48 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-02-03T03:40:48Z</dc:date>
    <item>
      <title>transpose truncating var values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/transpose-truncating-var-values/m-p/716295#M221348</link>
      <description>&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri" color="#000000"&gt;I’m having trouble with transpose truncating my data. In my regular code I get this error:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="background: white; color: red; font-family: 'Courier New';"&gt;ERROR: The ID value "'WHAT DO YOU FIND MOST CHALLENGIN'n" occurs twice in the same BY group.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri" color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri" color="#000000"&gt;I don’t get the error with this sample code but the questions in each column do get truncated. It could be that the questions in my regular code are much longer (around 100 characters).&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data test1;
     infile datalines delimiter=',';
     length ques_txt $200;
     input ques_txt $ person_id $ response $ uniqueid;
     datalines;
This question is nonsense about how long the question is,22,No,1
This question is more nonsense about nothing,22,Yes,2
This question is still more nonsense,22,Maybe,3
This question is nonsense about how long the question is,65,Yes,4
This question is more nonsense about nothing,65,Who knows,5
This question is still more nonsense,65,Si,6
This question is nonsense about how long the question is,44,No,7
This question is more nonsense about nothing,44,Yes,8
This question is still more nonsense,44,Not on your life,9
;
run;

proc sort data=test1 nodupkey out=test2;by person_id ques_txt  ;run;

proc transpose data=test2  out=test3 (drop=_name_ _label_);
     by person_id ;
     id ques_txt;
     var response;
run;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri" color="#000000"&gt;I should have added that the output should look like this. You can see that the questions in the column headers where cut off at 32 characters whereas these in the sample data are around 45 to 50 characters but the production questions are around 100 characters.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri" color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri" color="#000000"&gt;person_id This question is more nonsense a This question is nonsense about&amp;nbsp;&amp;nbsp;&amp;nbsp;This question is still more nons&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri" color="#000000"&gt;22&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Yes&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; No&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Maybe&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri" color="#000000"&gt;44&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Yes&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; No&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Not on y&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri" color="#000000"&gt;65&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Who know&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Yes&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Si&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri" color="#000000"&gt;Thanks&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 03:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/transpose-truncating-var-values/m-p/716295#M221348</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2021-02-03T03:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: transpose truncating var values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/transpose-truncating-var-values/m-p/716299#M221349</link>
      <description>&lt;P&gt;The ID statement in PROC TRANSPOSE lets you tell it what variable to use to NAME the variables it creates.&amp;nbsp; Variables in SAS can only by up to 32 characters long.&lt;/P&gt;
&lt;P&gt;If you want to attach those long descriptive text strings to the variables use the IDLABEL statement in PROC TRANSPOSE to use those strings as the LABEL to be attached to the variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
  infile datalines delimiter=',';
  length person_id $8 ques_txt $200 response $30 uniqueid 8;
  input ques_txt person_id response uniqueid;
datalines;
This question is nonsense about how long the question is,22,No,1
This question is more nonsense about nothing,22,Yes,2
This question is still more nonsense,22,Maybe,3
This question is nonsense about how long the question is,65,Yes,4
This question is more nonsense about nothing,65,Who knows,5
This question is still more nonsense,65,Si,6
This question is nonsense about how long the question is,44,No,7
This question is more nonsense about nothing,44,Yes,8
This question is still more nonsense,44,Not on your life,9
;
proc sort data=test1;
  by ques_txt;
run;

data test2 ;
  set test1;
  by ques_txt;
  ques_num + first.ques_txt;
run;

proc sort data=test2 nodupkey out=test3;
  by person_id ques_num;
run;

proc transpose data=test3 prefix=ques out=test4 (drop=_name_ _label_);
  by person_id ;
  id ques_num;
  idlabel ques_txt;
  var response;
run;

proc print data=test4;
run;
proc print data=test4 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: 603px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54254iD79875D0DA1FB273/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>Wed, 03 Feb 2021 03:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/transpose-truncating-var-values/m-p/716299#M221349</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-03T03:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: transpose truncating var values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/transpose-truncating-var-values/m-p/716492#M221445</link>
      <description>&lt;P&gt;That works. Thanks so much Tom.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 15:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/transpose-truncating-var-values/m-p/716492#M221445</guid>
      <dc:creator>DanD999</dc:creator>
      <dc:date>2021-02-03T15:20:09Z</dc:date>
    </item>
  </channel>
</rss>

