<?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: join multiple columns in one step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771906#M245022</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
input subject $ group $ result1 $ result2 $ result3 $;
datalines;
s1 a bl ye pu
s1 b re gr
s2 a bl re
s3 a ye pu re
;

data codes;
input code $ color $;
datalines;
re red
bl blue
gr green
pu purple
ye yellow
;

data format;
 set codes(rename=(code=start color=label));
 retain fmtname 'fmt' type 'C';
run;
proc format cntlin=format;run;

data want;
 set have;
 array x{*} $ 40 result1-result3;
 array y{*} $ 40 color1-color3;
do i=1 to dim(x);
 y{i}=put(x{i},$fmt.);
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 04 Oct 2021 11:25:12 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-10-04T11:25:12Z</dc:date>
    <item>
      <title>join multiple columns in one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771893#M245013</link>
      <description>&lt;P&gt;So i have a large dataset with around 2m rows and I want to join 30 of the columns and add a new variable for each result. I'm not great at describing data so here is what I have and what i want&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is an example dataset, keep in mind the real dataset has results1-30&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
input subject $ group $ result1 $ result2 $ result3 $;
datalines;
s1 a bl ye pu
s1 b re gr
s2 a bl re
s3 a ye pu re
;

data&amp;nbsp;codes;
input&amp;nbsp;code&amp;nbsp;$&amp;nbsp;color&amp;nbsp;$;
datalines;
re&amp;nbsp;red
bl&amp;nbsp;blue
gr&amp;nbsp;green
pu&amp;nbsp;purple
ye&amp;nbsp;yellow&lt;BR /&gt;;&lt;/CODE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;i want the dataset to look like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;subject group result1 result2 result3 color1 color2 color3
s1 a bl ye pu blue yellow purple
s1 b re gr red green
s2 a bl re blue red
s3 a ye pu re yellow purple red
;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a simple way to join multiple columns in one step? I can make 30 proc sqls but i feel like that would be incredibly inefficient. Any help would be appreciated, Thanks!&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;</description>
      <pubDate>Mon, 04 Oct 2021 10:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771893#M245013</guid>
      <dc:creator>togglefroggle</dc:creator>
      <dc:date>2021-10-04T10:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: join multiple columns in one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771894#M245014</link>
      <description>&lt;P&gt;Does it really have to be adding 30 new columns to a data set? Or can you simply apply a custom format, and that will suffice?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
     value $colorf 're'='red' 'bl'='blue' 'gr'='green'
         'pu'='purple' 'ye'='yellow';
run;
proc datasets noprint library=work;
     modify have;
     format result1-result30 $colorf.;
run;
     &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why is any of this worth the effort? What can you do with 'red' that you can't do with 're' ?? &lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 10:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771894#M245014</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-04T10:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: join multiple columns in one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771898#M245016</link>
      <description>So the example dataset im using are just made up variables i changed to colors because the real dataset has sensitive information. In actuality the "colors" are specific codes and I'm mapping them to codes used in a previous model, but the codes don't always map 1-1 so i want to retain both sets. Sorry if i should have included this information in my post.</description>
      <pubDate>Mon, 04 Oct 2021 11:01:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771898#M245016</guid>
      <dc:creator>togglefroggle</dc:creator>
      <dc:date>2021-10-04T11:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: join multiple columns in one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771900#M245017</link>
      <description>&lt;P&gt;Depending on what analysis you might do with your data, you can perform the analysis with the formats, and another analysis without the formats. I realize that may not work in all situations. What analysis will you be doing with these codes?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Oct 2021 11:06:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771900#M245017</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-04T11:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: join multiple columns in one step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771906#M245022</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
input subject $ group $ result1 $ result2 $ result3 $;
datalines;
s1 a bl ye pu
s1 b re gr
s2 a bl re
s3 a ye pu re
;

data codes;
input code $ color $;
datalines;
re red
bl blue
gr green
pu purple
ye yellow
;

data format;
 set codes(rename=(code=start color=label));
 retain fmtname 'fmt' type 'C';
run;
proc format cntlin=format;run;

data want;
 set have;
 array x{*} $ 40 result1-result3;
 array y{*} $ 40 color1-color3;
do i=1 to dim(x);
 y{i}=put(x{i},$fmt.);
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Oct 2021 11:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/join-multiple-columns-in-one-step/m-p/771906#M245022</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-04T11:25:12Z</dc:date>
    </item>
  </channel>
</rss>

