<?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: Concatnation of character and number into one variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506251#M135680</link>
    <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/26987"&gt;@sgarg&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Z&amp;nbsp; of size $7. or size $6(3+2+1)?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 20 Oct 2018 19:29:33 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-10-20T19:29:33Z</dc:date>
    <item>
      <title>Concatnation of character and number into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506250#M135679</link>
      <description>&lt;P&gt;Hi, I need to create a new variable from three variables. example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a = 'S'&amp;nbsp; --&amp;gt;&amp;nbsp;&amp;nbsp; of size 1 character&lt;/P&gt;&lt;P&gt;b = 'XYZ' ---&amp;gt;&amp;nbsp; of size 3 character. Here value of b can be&amp;nbsp; 'XY'&amp;nbsp; or 'X'&amp;nbsp; This means&amp;nbsp; size of variable is 3 but can have 2 character or 1 character value.&lt;/P&gt;&lt;P&gt;c = 11 ----&amp;gt;&amp;nbsp; this is 2 digit numeric&amp;nbsp; and can have values from 1 to 20&amp;nbsp; This means size of variable is 2 but can have 1 digit or 2 digit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to combined all three variable and&amp;nbsp; create new variable&amp;nbsp; Z&amp;nbsp; of size $7.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So as per Example&lt;/P&gt;&lt;P&gt;if&lt;/P&gt;&lt;P&gt;a = 'S'&amp;nbsp;&amp;nbsp; b = 'XY'&amp;nbsp; c = 1&amp;nbsp;&amp;nbsp; then&amp;nbsp; Z = 'SXY 01'&amp;nbsp; ( 1 space in between)&lt;/P&gt;&lt;P&gt;a = 'S'&amp;nbsp;&amp;nbsp; b = 'X'&amp;nbsp;&amp;nbsp;&amp;nbsp; c = 5&amp;nbsp;&amp;nbsp; then&amp;nbsp; Z = 'SX&amp;nbsp; 05'&amp;nbsp; ( two spaces in between)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried CAT, CATX, CATX&amp;nbsp; functions but not getting results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please Advice what i can do...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Oct 2018 19:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506250#M135679</guid>
      <dc:creator>sgarg</dc:creator>
      <dc:date>2018-10-20T19:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Concatnation of character and number into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506251#M135680</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/26987"&gt;@sgarg&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Z&amp;nbsp; of size $7. or size $6(3+2+1)?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Oct 2018 19:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506251#M135680</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-20T19:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Concatnation of character and number into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506253#M135682</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
length a $1 b $3 ;
a = 'S'  ; b ='XY' ; c = 1;
output;
a = 'S' ;  b = 'X'   ; c = 5 ;
output;
run;

data want;
set have;
length _c $2 z $6;
_c=put(c,z2.);
z=peekc(addr(a),1)||peekc(addr(b),3)||peekc(addr(_c),2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTES:&lt;/P&gt;
&lt;P&gt;1. We do not know your real data whether those variables are grouped contiguous. So the need for peekc *3 times. If it is contiguous, just extracting the left most var's addr of the leftmost byte with vlength combination of a,b,c will get the required in one shot.&lt;/P&gt;
&lt;P&gt;2. APP functions use is highly dependent on knowing data first.&lt;/P&gt;
&lt;P&gt;3. While for the description that you gave, that answered.&lt;/P&gt;
&lt;P&gt;4. Use the &lt;STRONG&gt;long&lt;/STRONG&gt; brethren if&amp;nbsp; you are working on 64 bit machine i.e substitute with peekclong, addrlong accordingly&lt;/P&gt;
&lt;P&gt;5. If you are not used to APP data management functions, ignore my post&lt;/P&gt;</description>
      <pubDate>Sat, 20 Oct 2018 19:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506253#M135682</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-20T19:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Concatnation of character and number into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506255#M135684</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Correct Z is of size&amp;nbsp; $6.&amp;nbsp; lol.. Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Oct 2018 19:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506255#M135684</guid>
      <dc:creator>sgarg</dc:creator>
      <dc:date>2018-10-20T19:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: Concatnation of character and number into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506256#M135685</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp; Thanks for your reply. I am using SAS Enterprise guide and got error see NOTE section below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;27&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data have;&lt;BR /&gt;28&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length a $1 b $3 ;&lt;BR /&gt;29&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a = 'S'&amp;nbsp; ; b ='XY' ; c = 1;&lt;BR /&gt;30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;31&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a = 'S' ;&amp;nbsp; b = 'X'&amp;nbsp;&amp;nbsp; ; c = 5 ;&lt;BR /&gt;32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&lt;BR /&gt;NOTE: The data set WORK.HAVE has 2 observations and 3 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;34&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;35&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data want;&lt;BR /&gt;36&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;BR /&gt;37&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length _c $2 z $6;&lt;BR /&gt;38&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _c=put(c,z2.);&lt;BR /&gt;39&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; z=peekc(addr(a),1)||peekc(addr(b),3)||peekc(addr(_c),2);&lt;BR /&gt;40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;NOTE: ADDR function cannot be used on this platform. Use ADDRLONG instead.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;NOTE: PEEKC function cannot be used on this platform. Use PEEKCLONG instead.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF9900"&gt;NOTE: There were 2 observations read from the data set WORK.HAVE.&lt;/FONT&gt;&lt;BR /&gt;NOTE: The data set WORK.WANT has 2 observations and 5 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Oct 2018 19:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506256#M135685</guid>
      <dc:creator>sgarg</dc:creator>
      <dc:date>2018-10-20T19:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Concatnation of character and number into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506257#M135686</link>
      <description>&lt;P&gt;Forget APP functions. How about CAT?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length a $1 b $3 ;
a = 'S'  ; b ='XY' ; c = 1;
output;
a = 'S' ;  b = 'X'   ; c = 5 ;
output;
run;

data want;
set have;
length _c $2 z $6;
_c=put(c,z2.);
z=cat(a,b,_c);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Oct 2018 20:03:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506257#M135686</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-20T20:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Concatnation of character and number into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506260#M135687</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp; Yes it worked. Thank you Thank you so much..&lt;/P&gt;</description>
      <pubDate>Sat, 20 Oct 2018 20:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506260#M135687</guid>
      <dc:creator>sgarg</dc:creator>
      <dc:date>2018-10-20T20:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: Concatnation of character and number into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506261#M135688</link>
      <description>&lt;P&gt;Finally for fun and completeness,&lt;/P&gt;
&lt;P&gt;My Notes above &lt;STRONG&gt;point 4.&lt;/STRONG&gt; emphasizes LONG APP' for the 64 bit machine, therefore the code changes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
length a $1 b $3 ;
a = 'S'  ; b ='XY' ; c = 1;
output;
a = 'S' ;  b = 'X'   ; c = 5 ;
output;
run;

data want;
set have;
length _c $2 z $6;
_c=put(c,z2.);
z=peekclong(addrlong(a),1)||peekclong(addrlong(b),3)||peekclong(addrlong(_c),2);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Oct 2018 20:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506261#M135688</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-20T20:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Concatnation of character and number into one variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506268#M135691</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/26987"&gt;@sgarg&lt;/a&gt;&amp;nbsp; Mark the post as answered having acknowledged the help. That completes and closes it.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Oct 2018 21:20:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatnation-of-character-and-number-into-one-variable/m-p/506268#M135691</guid>
      <dc:creator>Allaluiah</dc:creator>
      <dc:date>2018-10-20T21:20:53Z</dc:date>
    </item>
  </channel>
</rss>

