<?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 create a macro which will hold the suffix of second column name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514760#M138825</link>
    <description>&lt;P&gt;I have table as shown below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Sourcetable&lt;/TD&gt;&lt;TD&gt;Count_103018&lt;/TD&gt;&lt;TD&gt;Count_110518&lt;/TD&gt;&lt;TD&gt;Count_111218&lt;/TD&gt;&lt;TD&gt;Count_111918&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS&lt;/TD&gt;&lt;TD&gt;19,869&lt;/TD&gt;&lt;TD&gt;19,924&lt;/TD&gt;&lt;TD&gt;20,270&lt;/TD&gt;&lt;TD&gt;20,233&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS-Rater&lt;/TD&gt;&lt;TD&gt;16,429&lt;/TD&gt;&lt;TD&gt;16,569&lt;/TD&gt;&lt;TD&gt;16,893&lt;/TD&gt;&lt;TD&gt;17,125&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;InRaterOnly&lt;/TD&gt;&lt;TD&gt;18,662&lt;/TD&gt;&lt;TD&gt;18,702&lt;/TD&gt;&lt;TD&gt;18,691&lt;/TD&gt;&lt;TD&gt;19,235&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TOTAL&lt;/TD&gt;&lt;TD&gt;54,960&lt;/TD&gt;&lt;TD&gt;55,195&lt;/TD&gt;&lt;TD&gt;55,854&lt;/TD&gt;&lt;TD&gt;56,593&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a macro which will hold the suffix of second column name. Like for example the second column name here is Count_103018, So macro should hold 103018, (second column name will change as per the week)&lt;/P&gt;</description>
    <pubDate>Tue, 20 Nov 2018 14:35:26 GMT</pubDate>
    <dc:creator>subrat1</dc:creator>
    <dc:date>2018-11-20T14:35:26Z</dc:date>
    <item>
      <title>create a macro which will hold the suffix of second column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514760#M138825</link>
      <description>&lt;P&gt;I have table as shown below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Sourcetable&lt;/TD&gt;&lt;TD&gt;Count_103018&lt;/TD&gt;&lt;TD&gt;Count_110518&lt;/TD&gt;&lt;TD&gt;Count_111218&lt;/TD&gt;&lt;TD&gt;Count_111918&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS&lt;/TD&gt;&lt;TD&gt;19,869&lt;/TD&gt;&lt;TD&gt;19,924&lt;/TD&gt;&lt;TD&gt;20,270&lt;/TD&gt;&lt;TD&gt;20,233&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;CRS-Rater&lt;/TD&gt;&lt;TD&gt;16,429&lt;/TD&gt;&lt;TD&gt;16,569&lt;/TD&gt;&lt;TD&gt;16,893&lt;/TD&gt;&lt;TD&gt;17,125&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;InRaterOnly&lt;/TD&gt;&lt;TD&gt;18,662&lt;/TD&gt;&lt;TD&gt;18,702&lt;/TD&gt;&lt;TD&gt;18,691&lt;/TD&gt;&lt;TD&gt;19,235&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;TOTAL&lt;/TD&gt;&lt;TD&gt;54,960&lt;/TD&gt;&lt;TD&gt;55,195&lt;/TD&gt;&lt;TD&gt;55,854&lt;/TD&gt;&lt;TD&gt;56,593&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a macro which will hold the suffix of second column name. Like for example the second column name here is Count_103018, So macro should hold 103018, (second column name will change as per the week)&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 14:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514760#M138825</guid>
      <dc:creator>subrat1</dc:creator>
      <dc:date>2018-11-20T14:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: create a macro which will hold the suffix of second column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514763#M138827</link>
      <description>&lt;P&gt;Do you have that "table" as a SAS dataset or a text file or some other format?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 14:45:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514763#M138827</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-11-20T14:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: create a macro which will hold the suffix of second column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514764#M138828</link>
      <description>Hi:&lt;BR /&gt;  You are not providing enough information:&lt;BR /&gt;1) WHAT do you want to create macro VARIABLE, macro PROGRAM, use the value in a macro FUNCTION? Why do you need a "macro"?&lt;BR /&gt;2) WHY do you need the suffix of the column name? How are you going to use this value? Can you provide an example? What subsequent processing is going to be performed. You show 4 variables with numeric suffixes. Do you need to get the number from all 4 columns or only of the second column?&lt;BR /&gt;3) Your explanation implied that the second column name will change per week -- but you don't explain why this is significant? What happens to the column each week? Why does it change? Again, why do you need the suffix from only the second week?&lt;BR /&gt;4) What kind of process do you envision creating this new macro "something" with -- DATA step? SQL? simple %LET statements? Knowing What you're creating and how it's going to be used and having a picture of the entire process will help here.&lt;BR /&gt;5) What does your data file look like. Is the above your report output or your starting data table? Is this data already in SAS format or does it need to be read into SAS format? What kind of processing are you doing with the data. It is a rare data table that holds a TOTAL row. This looks like a report. Where does the report come from? How do you get this report/table? The structure of the data or file will impact the solution.&lt;BR /&gt;6) What code have you tried? &lt;BR /&gt;&lt;BR /&gt;  I'm hoping that these questions will allow you to define your needs in such a way that someone can make a constructive comment on your question.&lt;BR /&gt;&lt;BR /&gt;Cynthia</description>
      <pubDate>Tue, 20 Nov 2018 14:49:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514764#M138828</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-11-20T14:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: create a macro which will hold the suffix of second column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514765#M138829</link>
      <description>table as SAS dataset&lt;BR /&gt;</description>
      <pubDate>Tue, 20 Nov 2018 14:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514765#M138829</guid>
      <dc:creator>subrat1</dc:creator>
      <dc:date>2018-11-20T14:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: create a macro which will hold the suffix of second column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514766#M138830</link>
      <description>&lt;P&gt;You can query the dictionary.columns for the second variable in the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
		select strip(scan(name,2,'_')) into :var_2
			from dictionary.columns
				where libname='WORK'  /* Library name */
					and memname='HAVE'  /* Table name */
					and varnum=2       /* Variable 2 */
	;
quit;

%put &amp;amp;var_2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 14:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514766#M138830</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-11-20T14:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: create a macro which will hold the suffix of second column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514768#M138832</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsid=%sysfunc(open(dataset_name));
%let var_nm=%scan(%sysfunc(varname(&amp;amp;dsid,2)),2,'_');
%let dsid=%sysfunc(close(&amp;amp;dsid));
%put &amp;amp;=var_nm;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Nov 2018 14:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514768#M138832</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-11-20T14:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: create a macro which will hold the suffix of second column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514771#M138833</link>
      <description>&lt;P&gt;Assuming that the suffix on that names is date value in MMDDYY format (who uses two digit years? Y2K anyone?).&lt;/P&gt;
&lt;P&gt;Not sure you need any macro variables.&amp;nbsp; For example you could convert that structure to a TALL structure where the date value is actually in a variable instead of trapped in the variable's name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
   set have ;
  array _count count_: ;
  do month_no=1 to dim(_count);
     count=_count(month_no);
     date = input(scan(vname(_count(month_no)),2,'_'),mmddyy8.);
     output;
  end;
  format date yymmdd10. ;
  drop count_: ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 14:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-a-macro-which-will-hold-the-suffix-of-second-column-name/m-p/514771#M138833</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-11-20T14:58:53Z</dc:date>
    </item>
  </channel>
</rss>

