<?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: problem catx with macro variable passed in in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26429#M4709</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are still not counting the right thing.&amp;nbsp; You are counting the number of rows that PROC TRANSPOSE will generate.&amp;nbsp; You need to count the number of columns.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Mar 2012 02:13:29 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2012-03-09T02:13:29Z</dc:date>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26417#M4697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Main issue is that the macro variable mv is not passed, so, catx can't move on, how do I fix it? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data tmp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;length stmt $50;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; input cat stmt &amp;amp;$;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; datalines4;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;1 I am &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;1 good writer;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;2 statement sample here&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;;;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;proc transpose data=tmp out=trans (drop=_name_);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;by cat;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var stmt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/*sets number of cat variables into mv variable*/&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; select count(cat) into :mv from tmp group by cat;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; %let mv = &amp;amp;mv;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;data fnl(keep=x);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;set trans;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;x=catx(" ",col1-col&amp;amp;mv);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 00:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26417#M4697</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-03-09T00:24:45Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26418#M4698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp;&lt;/P&gt;&lt;P&gt;length stmt $50;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input cat stmt &amp;amp;$;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines4;&lt;/P&gt;&lt;P&gt;1 I am &lt;/P&gt;&lt;P&gt;1 good writer;&lt;/P&gt;&lt;P&gt;2 statement sample here&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=tmp out=trans (drop=_name_);&lt;/P&gt;&lt;P&gt;by cat;&lt;/P&gt;&lt;P&gt;var stmt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/*sets number of cat variables into mv variable*/&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select count(cat) into :mv from tmp group by cat;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%let mv = &amp;amp;mv;&lt;/P&gt;&lt;P&gt;data fnl(keep=x);&lt;/P&gt;&lt;P&gt;set trans;&lt;/P&gt;&lt;P&gt;x=catx(" ",of col1-col&amp;amp;mv);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 00:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26418#M4698</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-03-09T00:41:55Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26419#M4699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Can you help explain little bit:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why should I take %let mv=&amp;amp;mv; out side of proc sql?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Appreciate it!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 01:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26419#M4699</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-03-09T01:26:56Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26420#M4700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are you trying to accomplish?&amp;nbsp; From your code you appear to be trying to reach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp;&lt;/P&gt;&lt;P&gt;length stmt $50;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input cat stmt &amp;amp;$;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines4;&lt;/P&gt;&lt;P&gt;1 I am &lt;/P&gt;&lt;P&gt;1 good writer;&lt;/P&gt;&lt;P&gt;2 statement sample here&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=tmp out=trans (drop=_name_);&lt;/P&gt;&lt;P&gt;&amp;nbsp; by cat;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var stmt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fnl(keep=x);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set trans;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x=catx(" ",of col:);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, to answer your question, you are already creating a macro variable with your proc sql code.&amp;nbsp; Why try recreate the same variable with a %let statement.&amp;nbsp; Possibly I have missed something.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 01:40:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26420#M4700</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-03-09T01:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26421#M4701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;macro compiles way ahead of regular SAS code. so if you leave &amp;amp;mv inside SQL, it will try to be resovled long before 'select into' taking effect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 01:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26421#M4701</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-09T01:41:06Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26422#M4702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art, I believe OP just wanted to get rid of blanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 01:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26422#M4702</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-09T01:42:03Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26423#M4703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haikuo,&amp;nbsp; possibly, but that was never mentioned in the thread.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 01:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26423#M4703</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-03-09T01:44:27Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26424#M4704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know. Can you count how many time you have played mind-reading &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 01:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26424#M4704</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-09T01:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26425#M4705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are trying to determine how many columns PROC TRANSPOSE will create you are counting the wrong thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select max(n) into :mv&lt;/P&gt;&lt;P&gt;&amp;nbsp; from (select count(*) as n from tmp group by cat)&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To eliminate the spaces from your macro variable you can also use the SEPARATED BY clause after the target macro variable name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That said it is a lot easier and clearer to specify the variable range using COL: as Art suggested than to bother to re-process the data to find the count.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 01:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26425#M4705</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-09T01:58:59Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26426#M4706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think this is working, I added another group, catx, I lost "friend where are u"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp;&lt;BR /&gt;length stmt $50;&lt;BR /&gt;&amp;nbsp; input cat stmt &amp;amp;$;&lt;BR /&gt;&amp;nbsp; datalines4;&lt;BR /&gt;1 I am &lt;BR /&gt;1 good writer;&lt;BR /&gt;2 statement sample here&lt;BR /&gt;3 Hello&lt;BR /&gt;3 my&lt;BR /&gt;3 friend where are u&lt;BR /&gt;;;;;&lt;BR /&gt;proc transpose data=tmp out=trans (drop=_name_);&lt;BR /&gt;by cat;&lt;BR /&gt;var stmt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;/*sets number of cat variables into mv variable*/&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; select count(cat) into :mv from tmp group by cat;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%let mv = &amp;amp;mv;&lt;/P&gt;&lt;P&gt;data fnl(keep=x);&lt;BR /&gt;set trans;&lt;BR /&gt;x=catx(" ",of col1-col&amp;amp;mv);&lt;BR /&gt;run;&lt;/P&gt;&lt;DIV class="mcePaste" id="_mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;"&gt;﻿&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 02:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26426#M4706</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-03-09T02:02:55Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26427#M4707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I want to get final 3 lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am good writer;&lt;/P&gt;&lt;P&gt;Statement sample here&lt;/P&gt;&lt;P&gt;Hello my friend where are u&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use mv to pass it in the number of COL and then use catx to concatenate them&lt;/P&gt;&lt;P&gt;But it does not give me the right answer, I don't know how to fix it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 02:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26427#M4707</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-03-09T02:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26428#M4708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't lose anything with the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data tmp;&lt;/P&gt;&lt;P&gt;length stmt $50;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input cat stmt &amp;amp;$;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines4;&lt;/P&gt;&lt;P&gt;1 I am &lt;/P&gt;&lt;P&gt;1 good writer;&lt;/P&gt;&lt;P&gt;2 statement sample here&lt;/P&gt;&lt;P&gt;3 Hello&lt;/P&gt;&lt;P&gt;3 my&lt;/P&gt;&lt;P&gt;3 friend where are u&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=tmp out=trans (drop=_name_);&lt;/P&gt;&lt;P&gt;&amp;nbsp; by cat;&lt;/P&gt;&lt;P&gt;&amp;nbsp; var stmt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data fnl(keep=x);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set trans;&lt;/P&gt;&lt;P&gt;&amp;nbsp; x=catx(" ",of col:);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 02:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26428#M4708</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-03-09T02:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26429#M4709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are still not counting the right thing.&amp;nbsp; You are counting the number of rows that PROC TRANSPOSE will generate.&amp;nbsp; You need to count the number of columns.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 02:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26429#M4709</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-09T02:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26430#M4710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data tmp;&lt;/P&gt;&lt;P&gt;length stmt $50;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input cat stmt &amp;amp;$;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines4;&lt;/P&gt;&lt;P&gt;1 I am &lt;/P&gt;&lt;P&gt;1 good writer;&lt;/P&gt;&lt;P&gt;2 statement sample here&lt;/P&gt;&lt;P&gt;3 Hello&lt;/P&gt;&lt;P&gt;3 my&lt;/P&gt;&lt;P&gt;3 friend where are u&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;proc transpose data=tmp out=trans (drop=_name_);&lt;/P&gt;&lt;P&gt;by cat;&lt;/P&gt;&lt;P&gt;var stmt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/*sets number of cat variables into mv variable*/&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select count(distinct cat) into :mv from tmp ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%let mv = &amp;amp;mv;&lt;/P&gt;&lt;P&gt;data fnl(keep=x);&lt;/P&gt;&lt;P&gt;length x $ 100;&lt;/P&gt;&lt;P&gt;set trans;&lt;/P&gt;&lt;P&gt;x=catx(" ",of col1-col&amp;amp;mv);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am good writer;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; statement sample here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Hello my friend where are u&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 03:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26430#M4710</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-03-09T03:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26431#M4711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Linlin,&amp;nbsp; Your post, like the earlier onesl, confuses me.&amp;nbsp; Why use proc sql to create a macro variable, then use a %let statement to create the same macro variable that you created, and then use it when you could have just used col: ??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In fact, why create the macro variable at all?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have I missed something in this thread?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 03:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26431#M4711</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-03-09T03:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26432#M4712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Art,&lt;/P&gt;&lt;P&gt;The macro variable is not necessary at all. I just help Rick to fix his original code as he requested. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9; font-size: 12px; font-family: Arial, Helvetica, sans-serif;"&gt;Main issue is that the macro variable mv is not passed, so, catx can't move on, how do I fix it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9; font-size: 12px; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;STRONG&gt;data tmp;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;length stmt $50;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; input cat stmt &amp;amp;$;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; datalines4;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;1 I am &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;1 good writer;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;2 statement sample here&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;;;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9; font-size: 12px; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;STRONG&gt;proc transpose data=tmp out=trans (drop=_name_);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;by cat;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;var stmt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="background-color: #eef4f9; font-size: 12px; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;STRONG&gt;/*sets number of cat variables into mv variable*/&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;proc sql;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; select count(cat) into :mv from tmp group by cat;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; %let mv = &amp;amp;mv;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;data fnl(keep=x);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;set trans;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;x=catx(" ",col1-col&amp;amp;mv);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 03:55:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26432#M4712</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-03-09T03:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26433#M4713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with Art, when doing the transpose there is no reason to create the macro variable with you can use the variable list of col: but why do the transpose at all?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data foo;&lt;/P&gt;&lt;P&gt; input cat stmt &amp;amp; $20.;&lt;/P&gt;&lt;P&gt; cards;&lt;/P&gt;&lt;P&gt;1 I am&lt;/P&gt;&lt;P&gt;1 a good writer&lt;/P&gt;&lt;P&gt;2 statement sample here&lt;/P&gt;&lt;P&gt;3 Hello&lt;/P&gt;&lt;P&gt;3 my&lt;/P&gt;&lt;P&gt;3 friend where are you&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data bar;&lt;/P&gt;&lt;P&gt; set foo;&lt;/P&gt;&lt;P&gt; by cat;&lt;/P&gt;&lt;P&gt; length slurp $512;&lt;/P&gt;&lt;P&gt; retain slurp;&lt;/P&gt;&lt;P&gt; if first.cat then slurp=stmt; &lt;/P&gt;&lt;P&gt;&amp;nbsp; else slurp=catx(' ',slurp,stmt);&lt;/P&gt;&lt;P&gt; if last.cat then output;&lt;/P&gt;&lt;P&gt; keep slurp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;slurp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am a good writer&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;statement sample her&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Hello my friend where are you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additionally there are two other methods to get the number of columns from after the transpose that I do not think were mentioned yet like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;26&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc transpose&lt;/P&gt;&lt;P&gt;27&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data=foo&lt;/P&gt;&lt;P&gt;28&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=bar(drop=_:);&lt;/P&gt;&lt;P&gt;29&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by cat;&lt;/P&gt;&lt;P&gt;30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var stmt;&lt;/P&gt;&lt;P&gt;31&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: There were 6 observations read from the data set WORK.FOO.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.BAR has 3 observations and 5 variables.&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE TRANSPOSE used (Total process time):&lt;/P&gt;&lt;P&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;/P&gt;&lt;P&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;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql noprint;&lt;/P&gt;&lt;P&gt;34&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select nvar-1 into :nvar from sashelp.vtable where libname='WORK' and memname='BAR';&lt;/P&gt;&lt;P&gt;35&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select count(*) into :nvar2 from sashelp.vcolumn where libname='WORK' and memname='BAR' and name like 'COL%';&lt;/P&gt;&lt;P&gt;36&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* doesn't matter if I resolve here either */&lt;/P&gt;&lt;P&gt;37&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put nvar=%trim(%left(&amp;amp;nvar)) and nvar2=%trim(%left(&amp;amp;nvar2));&lt;/P&gt;&lt;P&gt;nvar=3 and nvar2=3&lt;/P&gt;&lt;P&gt;38&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&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;/P&gt;&lt;P&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.01 seconds&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 04:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26433#M4713</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2012-03-09T04:37:51Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26434#M4714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I count the number of row by group. so 1st group has 2 rows, 2nd has 1, 3rd has 3, &lt;/P&gt;&lt;P&gt;Then I transpose by combining the row, 1st group is 2 rows needed to be grouped, 2nd 1 row, 3rd needed 3 rows to be grouped.&lt;/P&gt;&lt;P&gt;I think count logic is right, unless I miss something?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26434#M4714</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-03-09T19:12:31Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26435#M4715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hello FriedEgg and art297,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you tell me the usage of &lt;STRONG&gt;":"&lt;/STRONG&gt; in x=catx(" ",of col:);?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it looks like it save the portion of using proc sql to create a macro variable to determine the number of rows too be concatenated in the catx.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26435#M4715</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-03-09T19:19:51Z</dc:date>
    </item>
    <item>
      <title>problem catx with macro variable passed in</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26436#M4716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FriedEgg: I tried your other two methods, looks like they don't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-catx-with-macro-variable-passed-in/m-p/26436#M4716</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-03-09T19:48:21Z</dc:date>
    </item>
  </channel>
</rss>

