<?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: How to combine two variables into one with a certain format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901774#M40224</link>
    <description>&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-concatenate-values-in-SAS/ta-p/494125" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-concatenate-values-in-SAS/ta-p/494125&lt;/A&gt;</description>
    <pubDate>Mon, 06 Nov 2023 18:51:15 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2023-11-06T18:51:15Z</dc:date>
    <item>
      <title>How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901770#M40221</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am working on a homework assignment, and part of the assignment is to take two variables 'FirstNm' and 'LastNm' and combine them into one variable titled 'Name' with the format last name, first name. How do I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 18:29:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901770#M40221</guid>
      <dc:creator>BLT2023</dc:creator>
      <dc:date>2023-11-06T18:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901772#M40222</link>
      <description>Look up the CATX() function.</description>
      <pubDate>Mon, 06 Nov 2023 18:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901772#M40222</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-11-06T18:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901773#M40223</link>
      <description>&lt;P&gt;One thing you need to be very aware of with SAS is that FORMAT has a very specify meaning related to display of values using a defined Format (read up on the procedure). The format at display time applies rules for displaying a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are discussing layout or order, not format.&lt;/P&gt;
&lt;P&gt;That involves concatenation in this case, the formal term for "sticking text together".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should define the length of the new variable before assigning values as the approach chosen could create extremely long values.&lt;/P&gt;
&lt;P&gt;You aren't clear whether the result should have a comma, a space or a comma and a space as a result.&lt;/P&gt;
&lt;P&gt;It is best to provide an actual example. Such as Firstnm='Bob' , Lastnm='Smith' and want Name='Smith, Bob'. Now we can see that you want to insert a comma and a space (if that is in fact the desired result).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What have you tried so far? I should think that your instructor provided at least some clues.&lt;/P&gt;
&lt;P&gt;If not, one clue: CATX function would be my preferred tool.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 21:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901773#M40223</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-11-06T21:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901774#M40224</link>
      <description>&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-concatenate-values-in-SAS/ta-p/494125" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-concatenate-values-in-SAS/ta-p/494125&lt;/A&gt;</description>
      <pubDate>Mon, 06 Nov 2023 18:51:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901774#M40224</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-11-06T18:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901786#M40225</link>
      <description>&lt;P&gt;I have tried:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data WORK.stjohns;
FirstNm = 'Daniel';
LastNm = 'Taylor';
length Name $ 12;
Name = catx(',', LastNm, FirstNm);
put _all_;
run;&lt;/PRE&gt;&lt;P&gt;It gave me nothing in my new variable. I am looking for&amp;nbsp;&lt;SPAN&gt;Firstnm='Daniel' , Lastnm='Taylor' and want Name='Taylor, Daniel'.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 20:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901786#M40225</guid>
      <dc:creator>BLT2023</dc:creator>
      <dc:date>2023-11-06T20:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901792#M40226</link>
      <description>&lt;P&gt;Your length statement is shorter than the desired character string. Change the length statement to allow bigger character strings.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 20:24:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901792#M40226</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-06T20:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901794#M40227</link>
      <description>&lt;P&gt;Thank you! I guess I miscounted. The output came out as "Taylor,Daniel"- how do I get a space in between the comma and the D?&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 20:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901794#M40227</guid>
      <dc:creator>BLT2023</dc:creator>
      <dc:date>2023-11-06T20:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901795#M40228</link>
      <description>&lt;P&gt;Also, a follow-up question: How do I do this for more than one name?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 20:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901795#M40228</guid>
      <dc:creator>BLT2023</dc:creator>
      <dc:date>2023-11-06T20:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901801#M40229</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/454937"&gt;@BLT2023&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you! I guess I miscounted. The output came out as "Taylor,Daniel"- how do I get a space in between the comma and the D?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I give you a hint: it is a tiny change to the CATX function first argument. I give another hint, which was previously given by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;: really, look at the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lefunctionsref/n0p7wxtk0hvn83n1pveisbcp2ae9.htm" target="_self"&gt;documentation for CATX&lt;/A&gt;, its all explained in there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;a follow-up question: How do I do this for more than one name?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is simply done in a DATA step, where you use the SET command to allow it to work on another SAS data set with lots of names.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 20:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901801#M40229</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-06T20:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901804#M40230</link>
      <description>&lt;P&gt;I am a bit confused by what you mean when you say (in reference to SET) '&lt;SPAN&gt;allow it to work on another SAS data set with lots of names.'&amp;nbsp; It is the same data set (I'musing data lines), but there are 2 more names within the data lines. that need catx. Does your statement about SET still apply? Thank you for clarifying.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 20:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901804#M40230</guid>
      <dc:creator>BLT2023</dc:creator>
      <dc:date>2023-11-06T20:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901821#M40231</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
set sashelp.class (keep=name rename=name=first_name); *this is your input data set;

last_name = "Flinstone"; *make a fake last name as there's no names in the data;

name = catx(", ", last_name, first_name); *create full name;

run;

proc print data=class;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2023 21:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/901821#M40231</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-11-06T21:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two variables into one with a certain format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/902034#M40255</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/454937"&gt;@BLT2023&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am a bit confused by what you mean when you say (in reference to SET) '&lt;SPAN&gt;allow it to work on another SAS data set with lots of names.'&amp;nbsp; It is the same data set (I'musing data lines), but there are 2 more names within the data lines. that need catx. Does your statement about SET still apply? Thank you for clarifying.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show us the SAS data set you are working with. (We don't need all of it, for example 5 lines ought to be good enough)&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 12:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-combine-two-variables-into-one-with-a-certain-format/m-p/902034#M40255</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-08T12:18:49Z</dc:date>
    </item>
  </channel>
</rss>

