<?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: Keep all unique column value in single row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802714#M316033</link>
    <description>&lt;P&gt;Thank you Amir, It works perfectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In that code, when I format the code using proc sql, its not working. Can you guide what is the mistake I am doing as I am new.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc format;
value abc 1='not present'
      2='Present'
      3='Available'
      ;
run;

proc sql;
	create table aa as
	select pid, age, visit format=abc., d1 
	from test;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 17 Mar 2022 22:35:51 GMT</pubDate>
    <dc:creator>abraham1</dc:creator>
    <dc:date>2022-03-17T22:35:51Z</dc:date>
    <item>
      <title>Keep all unique column value in single row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802710#M316031</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I want to create new column 'new_visit' where all visit information of unique patient available with repetilike below&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;pid&lt;/TD&gt;&lt;TD&gt;age&lt;/TD&gt;&lt;TD&gt;visit&lt;/TD&gt;&lt;TD&gt;d1&lt;/TD&gt;&lt;TD&gt;new_visit&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;101&lt;/TD&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;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&gt;25&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;1, 2,3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;104&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;1, 2,3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test;
input pid age visit d1 ;
cards;
101 21 1 1
101 21 2 1
101 21 1 4 
102 34 2 1 
103 31 1 1 
104 25 1 2
104 25 2 2
104 25 3 2
104 25 1 5
104 25 2 5
 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 21:31:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802710#M316031</guid>
      <dc:creator>abraham1</dc:creator>
      <dc:date>2022-03-17T21:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Keep all unique column value in single row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802713#M316032</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about the following?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input pid age visit d1 ;
	cards;
101 21 1 1
101 21 2 1
101 21 1 4 
102 34 2 1 
103 31 1 1 
104 25 1 2
104 25 2 2
104 25 3 2
104 25 1 5
104 25 2 5
;


data want;
	length new_visit $ 10;
	
	do until(last.pid);
		set have;
		by pid;
		
		new_visit = catx(',',new_visit,ifc(find(new_visit,cats(visit)),'',cats(visit)));
	end;
	
	do until(last.pid);
		set have;
		by pid;
		
		output;
	end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 21:56:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802713#M316032</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2022-03-17T21:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Keep all unique column value in single row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802714#M316033</link>
      <description>&lt;P&gt;Thank you Amir, It works perfectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In that code, when I format the code using proc sql, its not working. Can you guide what is the mistake I am doing as I am new.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc format;
value abc 1='not present'
      2='Present'
      3='Available'
      ;
run;

proc sql;
	create table aa as
	select pid, age, visit format=abc., d1 
	from test;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Mar 2022 22:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802714#M316033</guid>
      <dc:creator>abraham1</dc:creator>
      <dc:date>2022-03-17T22:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Keep all unique column value in single row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802715#M316034</link>
      <description>&lt;P&gt;"Not working" is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the "&amp;lt;&amp;gt;" to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "&amp;lt;&amp;gt;" icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 22:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802715#M316034</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-17T22:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Keep all unique column value in single row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802718#M316037</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;data test;
input pid age visit d1 ;
cards;
101 21 1 1
101 21 2 1
101 21 1 4 
102 34 2 1 
103 31 1 1 
104 25 1 2
104 25 2 2
104 25 3 2
104 25 1 5
104 25 2 5
 ;
run;

proc format;
value abc 1='not present'
      2='Present'
      3='Available'
      ;
run;

proc sql;
	create table aa as
	select pid, age, visit format=abc., d1 
	from test;
quit;
	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am not getting any error or warning in log but still it is not working.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 23:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802718#M316037</guid>
      <dc:creator>abraham1</dc:creator>
      <dc:date>2022-03-17T23:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: Keep all unique column value in single row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802725#M316044</link>
      <description>&lt;P&gt;That code ran fine for me.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Define what you mean by not working.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 01:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802725#M316044</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-18T01:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Keep all unique column value in single row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802727#M316045</link>
      <description>I don't know why the exact code is not formating the visit value in output dataset in Unix env. I can do the same with case statement which is working but not with this above aproach.</description>
      <pubDate>Fri, 18 Mar 2022 02:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802727#M316045</guid>
      <dc:creator>Hemamalini</dc:creator>
      <dc:date>2022-03-18T02:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Keep all unique column value in single row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802733#M316049</link>
      <description>&lt;P&gt;Show us the log for the data step, the proc format and the proc sql. Include the code and all the messages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 04:41:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802733#M316049</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-18T04:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Keep all unique column value in single row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802757#M316066</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run the code, the table aa has been created as per the below screenshot, please show what your aa table looks like and point out &lt;U&gt;what&lt;/U&gt; value is wrong and &lt;U&gt;what&lt;/U&gt; you think it should be and &lt;U&gt;why&lt;/U&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lastly, are you sure you are looking at the table "aa" and not the table "test"&lt;SPAN&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="Amir_0-1647594279698.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69548i545C775D02B78409/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Amir_0-1647594279698.png" alt="Amir_0-1647594279698.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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 09:11:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-all-unique-column-value-in-single-row/m-p/802757#M316066</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2022-03-18T09:11:01Z</dc:date>
    </item>
  </channel>
</rss>

