<?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: Need Help with my Code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/462104#M117581</link>
    <description>&lt;P&gt;Thank you. The code provided by art297 worked for me. Reason why I had to do is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am validating an oncology ae data set that has related records whose values I am concatenating&amp;nbsp; as per specs. Thank you all for the great support.&lt;/P&gt;</description>
    <pubDate>Mon, 14 May 2018 15:49:16 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2018-05-14T15:49:16Z</dc:date>
    <item>
      <title>Need Help with my Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/461711#M117482</link>
      <description>&lt;P&gt;Dear ,&lt;/P&gt;
&lt;P&gt;I am concatenating variable "value" values by id and seq until 200 characters&amp;nbsp; in "value1" variable and&amp;nbsp; next 200-400 charaters in value2. I got the output I need for this simple data set as i know that I need only two variables(value1 and value2).&amp;nbsp; In my actual data&lt;SPAN&gt;&amp;nbsp;I do not know and may need up to value1-value 6&lt;/SPAN&gt;. How to modify my code to get required variables depending on length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eg :&lt;/P&gt;
&lt;P&gt;output needed (I put only a sample output for value1 variable).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;value1&lt;/P&gt;
&lt;P&gt;2001*3005*4001*4013*4015*4017*4019*4021*4023*4027*5033*5039*5041*5047*5051*5055*5059*5063*5067*5071*5075*5081*5091*5095*5101*5105*5109*5115*5127*5131*5133*5137*5143*5147*5151*5155*5159*5169*5173*5177*&lt;BR /&gt;2001*3005*4001*4013*4015*4017*4019*4021*4023*4027*5033*5039*5041*5047*5051*5055*5059*5063*5067*5071*5075*5081*5091*5095*5101*5105*5109*5115*5127*5131*5133*5137*5143*5147*5151*5155*5159*5169*5173*5177*&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data one;
input id seq value $;
datalines;
1 1 2000
1 1 3000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 4000
1 1 2000
1 1 3000
1 1 4000
1 1 4000
1 1 9000
1 1 2000
1 1 3000
1 1 4000
1 2 5000
1 2 6000
1 3 7000
;
proc sort data=one;
by id seq value;
run;

data two;
length value1 value2 $200;
do until(last.seq);
set one;
by id seq;
if first.seq then value1=value;
else do;
if length(value1) &amp;lt;200 then do;
value1=catx('*',value1,value);
end;
else if (length(value1) &amp;gt;=200)  and (length(value2) &amp;lt;200) then value2=catx('*',value2,value);
if last.seq then output;
end;
end;
value1='';
value2='';
keep id value1 value2;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 May 2018 21:35:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/461711#M117482</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-05-11T21:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with my Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/461714#M117483</link>
      <description>&lt;P&gt;How are those "value" variables to be used? Often when you don't know how many of these you need that is a symptom that the basic approach may have a flaw.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also since your are talking about a maximum of 6 variables each of 200 characters long why wouldn't one variable of up to 1200 characters (give or take) work?&lt;/P&gt;
&lt;P&gt;200 used to be the limit of character variables but that limit has increased considerably.&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 21:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/461714#M117483</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-11T21:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with my Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/461716#M117484</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; wrote:&lt;SPAN class="lia-button-wrapper lia-button-wrapper-secondary"&gt;&lt;A id="link_15" class="lia-button lia-button-secondary reply-action-link lia-action-reply" href="https://communities.sas.com/t5/forums/replypage/board-id/programming/message-id/117483" target="_blank" rel="nofollow"&gt;Reply&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;
&lt;P&gt;How are those "value" variables to be used? Often when you don't know how many of these you need that is a symptom that the basic approach may have a flaw.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also since your are talking about a maximum of 6 variables each of 200 characters long why wouldn't one variable of up to 1200 characters (give or take) work?&lt;/P&gt;
&lt;P&gt;200 used to be the limit of character variables but that limit has increased considerably.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I was thinking similar things to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;, I can't imagine any usefulness to a long string of 200 (or 1200) characters as described, and there must be a better approach.&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 21:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/461716#M117484</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-11T21:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with my Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/461720#M117485</link>
      <description>&lt;P&gt;One possibility is simply to have SAS do all of the grunt work. e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=one;
  by id seq value;
run;

data _null_;
  set one end=eof;
  by id seq;
  length value1 $200;
  retain value1 maxi;
  if first.seq then do;
    i=1;
    value1=value;
  end;
  else do;
    if length(catx('*',value1,value)) le 200 then
     value1=catx('*',value1,value);
    else do;
      i+1;
      value1=value;
    end;
  end;
  if last.seq then do;
    maxi=max(maxi,i);
    i=0;
  end;
  if eof then do;
    call symput('maxi',catt('value',maxi));
    i=0;
  end;
run;

data two (drop=value);
  array values(*) $200 value1-&amp;amp;maxi.;
  set one;
  by id seq;
  retain values;
  if first.seq then do;
    i=1;
    call missing(of values(*));
    values(i)=value;
  end;
  else do;
    if length(catx('*',values(i),value)) le 200 then
     values(i)=catx('*',values(i),value);
    else do;
      i+1;
      values(i)=value;
    end;
  end;
  if last.seq then output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 22:26:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/461720#M117485</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-05-11T22:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with my Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/461754#M117493</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/68272"&gt;@knveraraju91&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I'd be really curious WHY you're doing this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does below code return what you're after?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data two;
  length cat_val $200;
  retain cat_val;
  set one;
  by id seq;

  if lengthn(catx('*',cat_val,value))&amp;gt;200 then
    do;
      output;
      call missing(cat_val);
    end;

  cat_val=catx('*',cat_val,value);

  if last.seq then
    do;
      output;
      call missing(cat_val);
    end;

run;

proc transpose data=two out=want prefix=value_;
  by id seq;
  var cat_val;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 May 2018 03:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/461754#M117493</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-12T03:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with my Code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/462104#M117581</link>
      <description>&lt;P&gt;Thank you. The code provided by art297 worked for me. Reason why I had to do is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am validating an oncology ae data set that has related records whose values I am concatenating&amp;nbsp; as per specs. Thank you all for the great support.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 15:49:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Help-with-my-Code/m-p/462104#M117581</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-05-14T15:49:16Z</dc:date>
    </item>
  </channel>
</rss>

