<?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 Concatenating string and numeric values in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803903#M33362</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am working on a data set flattened using proc transpose. The resulting set has 34 columns or two variables. I would like to concatenate these columns into two (one for each variable). I used the CATX function in this manner:&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;length Medication $200 Response $200;&lt;BR /&gt;set have;&lt;BR /&gt;Medication=catx(",", Medication1-Medication34);&lt;BR /&gt;Response=catx(",", Response1-Response34);&lt;BR /&gt;drop Medication1-Medication34&amp;nbsp; Response1-Response34;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;but it didn't work producing to variables with all blanks. No error and no warning.&lt;/P&gt;&lt;P&gt;Any suggestions/tips on where I went wrong? Also, if I were to do the same thing with numeric variables, which concatenation function would be the best to use?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 24 Mar 2022 20:49:20 GMT</pubDate>
    <dc:creator>Ihsan-Mahdi</dc:creator>
    <dc:date>2022-03-24T20:49:20Z</dc:date>
    <item>
      <title>Concatenating string and numeric values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803903#M33362</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am working on a data set flattened using proc transpose. The resulting set has 34 columns or two variables. I would like to concatenate these columns into two (one for each variable). I used the CATX function in this manner:&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;length Medication $200 Response $200;&lt;BR /&gt;set have;&lt;BR /&gt;Medication=catx(",", Medication1-Medication34);&lt;BR /&gt;Response=catx(",", Response1-Response34);&lt;BR /&gt;drop Medication1-Medication34&amp;nbsp; Response1-Response34;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;but it didn't work producing to variables with all blanks. No error and no warning.&lt;/P&gt;&lt;P&gt;Any suggestions/tips on where I went wrong? Also, if I were to do the same thing with numeric variables, which concatenation function would be the best to use?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 20:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803903#M33362</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2022-03-24T20:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating string and numeric values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803905#M33363</link>
      <description>&lt;P&gt;Sorry, related to my question this is an example of what I have:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Medication1&lt;/TD&gt;&lt;TD&gt;Medication2&lt;/TD&gt;&lt;TD&gt;Medication…&lt;/TD&gt;&lt;TD&gt;Medication34&lt;/TD&gt;&lt;TD&gt;Response1&lt;/TD&gt;&lt;TD&gt;Response2&lt;/TD&gt;&lt;TD&gt;Response….&lt;/TD&gt;&lt;TD&gt;Response34&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;TD&gt;W&lt;/TD&gt;&lt;TD&gt;E&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&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what I want:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Medication&lt;/TD&gt;&lt;TD&gt;Response&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;X, Y, Z, W&lt;/TD&gt;&lt;TD&gt;E&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Y, H&lt;/TD&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;A, B, C&lt;/TD&gt;&lt;TD&gt;G, H&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;M, N, O, R&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;M, K, L, P&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Thu, 24 Mar 2022 20:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803905#M33363</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2022-03-24T20:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating string and numeric values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803906#M33364</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Medication1-Medication34&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is a calculation, unless you use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;of Medication1-Medication34&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to indicate to the data step compiler that this is in fact a variable list. But I don't know if this will work with CATX, and I can't test it here on my tablet.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 21:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803906#M33364</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-24T21:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating string and numeric values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803911#M33365</link>
      <description>&lt;P&gt;WOW! This actually worked, thank you so much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Would it work on numeric values?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 21:37:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803911#M33365</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2022-03-24T21:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating string and numeric values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803912#M33366</link>
      <description>&lt;P&gt;Did't work 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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Really, the LOG told you pretty much exactly what happens. Here is a very brief example of making a small data set and the using a couple of ways to do what you want and what you did incorrectly:&lt;/P&gt;
&lt;PRE&gt;data example;
  input x1 $ x2 $ x3 $;
datalines;
a b c
p d .
;

data want;
  set example;
  result1 = catx(',', of x:);
  result2 = catx(',', of x1-x3);
  result3 = catx(',',x1-x3);
run;&lt;/PRE&gt;
&lt;P&gt;And here's the Invalid data message that you got from your approach, Result3 above:&lt;/P&gt;
&lt;PRE&gt;80   data want;
81     set example;
82     result1 = catx(',', of x:);
83     result2 = catx(',', of x1-x3);
84     result3 = catx(',',x1-x3);
85   run;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      84:22   84:25
NOTE: Invalid numeric data, x1='a' , at line 84 column 22.
NOTE: Invalid numeric data, x3='c' , at line 84 column 25.
x1=a x2=b x3=c result1=a,b,c result2=a,b,c result3=. _ERROR_=1 _N_=1
NOTE: Invalid numeric data, x1='p' , at line 84 column 22.
x1=p x2=d x3=  result1=p,d result2=p,d result3=. _ERROR_=1 _N_=2
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      2 at 84:24
&lt;/PRE&gt;
&lt;P&gt;Large economy sized hints from the Log: First is the character converted to numeric note on the line for Result3.&lt;/P&gt;
&lt;P&gt;Then the "invalid numeric" notes for the character values and that &lt;STRONG&gt;only&lt;/STRONG&gt; two of them show the conversion. Lastly the "result of performing and operation on missing values" .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 21:42:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803912#M33366</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-24T21:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating string and numeric values</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803977#M33380</link>
      <description>&lt;P&gt;To use numeric data in character functions, you must make sure that the conversion happens in an orderly manner. Use the PUT function and proper formats to avoid unwanted blanks etc.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 06:05:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Concatenating-string-and-numeric-values/m-p/803977#M33380</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-25T06:05:49Z</dc:date>
    </item>
  </channel>
</rss>

