<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/770546#M244475</link>
    <description>&lt;P&gt;Can you please post some sample data?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 26 Sep 2021 21:07:15 GMT</pubDate>
    <dc:creator>tarheel13</dc:creator>
    <dc:date>2021-09-26T21:07:15Z</dc:date>
    <item>
      <title>Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/770544#M244474</link>
      <description>&lt;PRE&gt;I need some advice
I need to transpose 2 variables from a long dataset to a wide dataset
In the long dataset dad19sas.diagnosis the by variable dad_transaction_id  repeats or there are &lt;BR /&gt;duplicates for every different value of the var variables

Can i transpose both variables for a dad_transaction_id in a single proc transpose step &lt;BR /&gt;or do i do it in multiple steps.
If in multiple steps then do I use the merge to combine in a single dataset
I then wa&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/**Do I transpose in 2 seperate steps or a sinle step**/

proc transpose data = dad19sas.diagnosis out = diagcode 
prefix = DIAG_CODE_ ; 
var diag_icd10_code  ; 
by dad_transaction_id; 
run;

proc transpose data = dad19sas.diagnosis out = diagtype 
prefix = DIAG_type_code ; 
var diag_type_code  ; 
by dad_transaction_id; 
run;
/**Merge datasets by dad_transaction_id?**/

data diagcode;set diagcode; drop _NAME_ _LABEL_;run;

data diagcode;
set diagcode;
array diag{*} DIAG_CODE_: ;
array diag_type{*} DIAG_TYPE_CODE_:
do i = 1 to dim(diag); 
if diag{i} in: ('Z37') then DIAG_HD = 1;
end;
do i = 1 to dim(diag_type); 
if diag_type{i} in: ('M' or '3') then DIAG_HD_type = 1;
end;
/** Keep records with selected diagnosis above and where the type is M or 3 in any of the array elements*/
*if DIAG_HD = 1 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;nt to use the array statement on the transposed dataset to keep records &lt;BR /&gt;where diag_type_code =M or 3 and Please advise how I can perform the above&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Sep 2021 21:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/770544#M244474</guid>
      <dc:creator>Baba9</dc:creator>
      <dc:date>2021-09-26T21:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/770546#M244475</link>
      <description>&lt;P&gt;Can you please post some sample data?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Sep 2021 21:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/770546#M244475</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2021-09-26T21:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/770548#M244476</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/181158"&gt;@tarheel13&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can you please post some sample data?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Showing both starting data and desired result for the starting data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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>Sun, 26 Sep 2021 22:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-transpose/m-p/770548#M244476</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-26T22:15:03Z</dc:date>
    </item>
  </channel>
</rss>

