<?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 how i can resolve this kind of scenario in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932115#M366691</link>
    <description>&lt;P&gt;You could call this combining values by ID. I'm sure there's a better name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
input  ID VALUE$;
datalines;
101 V1
101 V2
101 V3
102 V4
102 V5
;
run;

data want (rename = (values = value) drop = value);
	do until (last.id);
		set have;
		by id;
		put value = ;
		put id = ;
		if first.id then values = value;
			else if not first.id then do;
				values = catx(" ", values, value);
				put values = ;
				put id = ;
			end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;ID	value
101	V1 V2 V3
102	V4 V5&lt;/PRE&gt;
&lt;P&gt;Note that your data set will need to be sorted by ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the PUT statements so that you can look at the log to see how it is working internally.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; 69         data want (rename = (values = value) drop = value);
 70         do until (last.id);
 71         set have;
 72         by id;
 73         put value = ;
 74         put id = ;
 75         if first.id then values = value;
 76         else if not first.id then do;
 77         values = catx(" ", values, value);
 78         put values = ;
 79         put id = ;
 80         end;
 81         end;
 82         run;
 
 VALUE=V1
 ID=101
 VALUE=V2
 ID=101
 values=V1 V2
 ID=101
 VALUE=V3
 ID=101
 values=V1 V2 V3
 ID=101
 VALUE=V4
 ID=102
 VALUE=V5
 ID=102
 values=V4 V5
 ID=102&lt;/PRE&gt;</description>
    <pubDate>Thu, 13 Jun 2024 12:26:11 GMT</pubDate>
    <dc:creator>maguiremq</dc:creator>
    <dc:date>2024-06-13T12:26:11Z</dc:date>
    <item>
      <title>Need help how i can resolve this kind of scenario</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932110#M366687</link>
      <description>&lt;P&gt;data set values are below:?&lt;BR /&gt;data have ;&lt;/P&gt;&lt;P&gt;input&amp;nbsp;&amp;nbsp;ID VALUE$;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;101 V1&lt;BR /&gt;101 V2&lt;BR /&gt;101 V3&lt;BR /&gt;102 V4&lt;BR /&gt;102 V5&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want output in new data set&amp;nbsp; like below:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;ID VALUE&lt;BR /&gt;101 V1,V2,V3&lt;BR /&gt;102 V4,V5&lt;BR /&gt;&lt;BR /&gt;please help thanks in advance&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 12:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932110#M366687</guid>
      <dc:creator>ganeshmule</dc:creator>
      <dc:date>2024-06-13T12:01:49Z</dc:date>
    </item>
    <item>
      <title>Poor Subject Line; Better Subject Line Needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932111#M366688</link>
      <description>&lt;P&gt;Please go back to your post and change the subject line to provide a meaningful subject line that &lt;EM&gt;briefly&lt;/EM&gt; describes the problem you are trying to solve. Saying you need help or how to fix/resolve an issue isn't a good subject line. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 12:00:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932111#M366688</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-13T12:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: Poor Subject Line; Better Subject Line Needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932113#M366689</link>
      <description>Thanks corrected&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Jun 2024 12:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932113#M366689</guid>
      <dc:creator>ganeshmule</dc:creator>
      <dc:date>2024-06-13T12:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Poor Subject Line; Better Subject Line Needed</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932114#M366690</link>
      <description>&lt;P&gt;We're going to try to help you, but you have to help us too. You didn't briefly describe the problem you are trying to solve. Saying "need help" or "you can't resolve a problem" is not a good subject line. This forum would be useless if all post subject lines were: "Help" "I need help" "Can't get this to work" "Not Working" "Help".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your previous posts did briefly describe the problem you are trying to solve, so I know you can do it.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 12:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932114#M366690</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-13T12:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help how i can resolve this kind of scenario</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932115#M366691</link>
      <description>&lt;P&gt;You could call this combining values by ID. I'm sure there's a better name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
input  ID VALUE$;
datalines;
101 V1
101 V2
101 V3
102 V4
102 V5
;
run;

data want (rename = (values = value) drop = value);
	do until (last.id);
		set have;
		by id;
		put value = ;
		put id = ;
		if first.id then values = value;
			else if not first.id then do;
				values = catx(" ", values, value);
				put values = ;
				put id = ;
			end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;ID	value
101	V1 V2 V3
102	V4 V5&lt;/PRE&gt;
&lt;P&gt;Note that your data set will need to be sorted by ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the PUT statements so that you can look at the log to see how it is working internally.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; 69         data want (rename = (values = value) drop = value);
 70         do until (last.id);
 71         set have;
 72         by id;
 73         put value = ;
 74         put id = ;
 75         if first.id then values = value;
 76         else if not first.id then do;
 77         values = catx(" ", values, value);
 78         put values = ;
 79         put id = ;
 80         end;
 81         end;
 82         run;
 
 VALUE=V1
 ID=101
 VALUE=V2
 ID=101
 values=V1 V2
 ID=101
 VALUE=V3
 ID=101
 values=V1 V2 V3
 ID=101
 VALUE=V4
 ID=102
 VALUE=V5
 ID=102
 values=V4 V5
 ID=102&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jun 2024 12:26:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932115#M366691</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2024-06-13T12:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need help how i can resolve this kind of scenario</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932118#M366694</link>
      <description>&lt;P&gt;I am 100% sure that problem very similar to yours have been solved here at least a dozen times ...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=transposed(drop=_name_);
    by id;
    var value;
run;

data want;
    set transposed;
    length value $ 100;

    value = catx(",", of col:);

    drop col:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jun 2024 12:48:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-how-i-can-resolve-this-kind-of-scenario/m-p/932118#M366694</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2024-06-13T12:48:33Z</dc:date>
    </item>
  </channel>
</rss>

