<?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: resolving macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376654#M90421</link>
    <description>&lt;P&gt;The next step would be to create a new list that is a subset of the candidates for removal based on the expected levels&amp;nbsp;... using macro language only, create a list of those variable names that should be removed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have trouble getting that to work, show what you have attempted and we can work with it.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jul 2017 17:02:35 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-07-17T17:02:35Z</dc:date>
    <item>
      <title>resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376605#M90412</link>
      <description>&lt;P&gt;I am trying to loop through variable names in a list to determine if it meets a condition. If it does then I need to revise the list of variables in &amp;nbsp;a variable named grp_lst. I would like to replace the variable name in the list with blank which by the end of the loop I will have a final variable list. Here is my sample code. I am using this in a macro so I created a little test macro around the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's assume that the &amp;amp;actual = 2 for Age and that the value in the drug1 dataset is 'age gender type' . After this code I would expect to see 'gender type' in the grp_lst.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variables that are needed and that are created prior to this code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var_lst = age gender type ;
%let varCount = 3 ;
%let expected = 3 3 6 ;

/*expected value for each variable in the var_lst */
%macro test();
	%DO k=1 %to &amp;amp;varCount;

		/*get the actual count for each variable in variable list*/
		proc sql NOPRINT;
			Select count(distinct %Scan(&amp;amp;var_lst, &amp;amp;k)) as %Scan(&amp;amp;var_lst, &amp;amp;k)_lvls 
				into :actual separated by ' ' from drug1;
		quit;

		/* create revised grp_lst by removing variables in the list if actual &amp;lt; expected */
		/* currently data in grp_lst is equal to var_lst&amp;nbsp;for all observations - just the way it was created..*/
		DATA drug1;
			set drug1;

			if &amp;amp;actual. &amp;lt; %Scan(&amp;amp;expected., &amp;amp;k.) then
				grp_lst=%sysfunc(compress(%sysfunc(tranwrd(grp_lst, "%Scan(&amp;amp;var_lst,&amp;amp;k)", 
					" "))));
		run;

	%END;
%MEND;

%test();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;This is what gets resolved in the log for the grp_list statement in the datastep:&lt;/P&gt;
&lt;P&gt;MPRINT(test &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&amp;nbsp;if 2&amp;nbsp;&amp;lt; 3&amp;nbsp;then grp_lst = grp_lst ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 15:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376605#M90412</guid>
      <dc:creator>CP2</dc:creator>
      <dc:date>2017-07-17T15:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376629#M90415</link>
      <description>&lt;P&gt;Use an array - remember Base SAS programming is used for data processing, Macro&amp;nbsp;&lt;U&gt;only&lt;/U&gt; creates text!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data drug1;
  set drug1;
  array vals{*} age gender type;
  do i=1 to dim(vals);
   &amp;lt;do your logic here&amp;gt;;
  end;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 16:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376629#M90415</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-17T16:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376642#M90416</link>
      <description>&lt;P&gt;You are mixing up macro language and DATA step code&amp;nbsp; in ways that have no chance of working properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make this a macro language problem until you have your new list defined.&amp;nbsp; Then (if desirable) you can replace GRP_LST in the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the basics of how to get started.&amp;nbsp; (There's a %DO loop, so this takes place inside a macro definition.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set drug1 (obs=1);&lt;/P&gt;
&lt;P&gt;call symputx('original_list' , grp_lst);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %do k=1 %to &amp;amp;varCount;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let next_name = %scan(&amp;amp;var_lst, &amp;amp;k);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select count(distinct &amp;amp;next_name) into&amp;nbsp; : &amp;amp;next_name from drug1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This gives you macro variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;ORIGINAL_LIST is all of the variables (a copy of the DATA step variable GRP_LST)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;VAR_LST is a list of variables to test to see if they should be removed from &amp;amp;ORIGINAL_LIST&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;AGE is the number of distinct levels for AGE that exist in the DRUG1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;GENDER is the number of distinct levels for GENDER that exist in DRUG1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;TYPE is the number of distinct levels for TYPE that exist in DRUG1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using macro language only, construct the list that you would like to replace GRP_LST in DRUG1.&amp;nbsp; There should not be another reference to DRUG1 until that list has been constructed as a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 16:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376642#M90416</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-17T16:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376650#M90418</link>
      <description>&lt;P&gt;Thanks but I still have the same problem with using a condition when actual levels are less than expected levels which will determine the final list of variables. i tried using %eval() in my originial code but that didn't work&amp;nbsp;either.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 16:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376650#M90418</guid>
      <dc:creator>CP2</dc:creator>
      <dc:date>2017-07-17T16:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376654#M90421</link>
      <description>&lt;P&gt;The next step would be to create a new list that is a subset of the candidates for removal based on the expected levels&amp;nbsp;... using macro language only, create a list of those variable names that should be removed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have trouble getting that to work, show what you have attempted and we can work with it.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 17:02:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376654#M90421</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-17T17:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376659#M90423</link>
      <description>&lt;P&gt;thank you. I tried your solution (adding an addtional type variable from original post) but am getting errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA drug1 ;&lt;BR /&gt;SET drug1 ;&lt;BR /&gt;ARRAY varlst[&amp;amp;varCount.] &amp;amp;var_lst. ;&lt;BR /&gt;array act{&amp;amp;varCount.} (&amp;amp;par_lvl.) ;&lt;BR /&gt;array exp{&amp;amp;varCount.} (&amp;amp;s_lvl.) ;&lt;BR /&gt;%do j = 1 %to &amp;amp;varCount. ;&lt;BR /&gt;if act[j] &amp;lt; exp[j] then grp_lst = tranwrd(grp_lst, arr_lst[j], " " ) ;&lt;BR /&gt;%end ;&lt;BR /&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MPRINT(temp): DATA drug1 ;&lt;BR /&gt;MPRINT(temp): SET drug1 ;&lt;BR /&gt;MPRINT(temp): ARRAY varlst[ 4] AGE GENDER TYPE1 TYPE2&amp;nbsp;&amp;nbsp;;&lt;BR /&gt;MPRINT(temp): array act{ 4} (3 2 2 5) ;&lt;BR /&gt;MPRINT(temp): array exp{ 4} (3 3 3 6 ) ;&lt;BR /&gt;MPRINT(temp): if act[j] &amp;lt; exp[j] then grp_lst = tranwrd(grp_lst, var_lst[j], " " ) ;&lt;BR /&gt;MPRINT(temp): if act[j] &amp;lt; exp[j] then grp_lst = tranwrd(grp_lst, var_lst[j], " " ) ;&lt;BR /&gt;MPRINT(temp): if act[j] &amp;lt; exp[j] then grp_lst = tranwrd(grp_lst, var_lst[j], " " ) ;&lt;BR /&gt;MPRINT(temp): if act[j] &amp;lt; exp[j] then grp_lst = tranwrd(grp_lst, var_lst[j], " " ) ;&lt;BR /&gt;MPRINT(temp): run ;&lt;/P&gt;&lt;P&gt;NOTE: Variable j is uninitialized.&lt;BR /&gt;ERROR: Array subscript out of range at line 697 column 12.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 17:15:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376659#M90423</guid>
      <dc:creator>CP2</dc:creator>
      <dc:date>2017-07-17T17:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376660#M90424</link>
      <description>&lt;P&gt;You're still mixing macro and non-macro code. Remove the two % (i.e., just use do and end)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 17:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376660#M90424</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-17T17:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376666#M90426</link>
      <description>&lt;P&gt;Thanks. It is the macro programming that is causing my confusion so I'm not following, sorry. Basically I have&lt;/P&gt;&lt;P&gt;an EXPECTED variable list and associated EXPECTED values in two macro variables (&amp;amp;var_lst, &amp;amp;var_lvl) .&amp;nbsp;I can create a&amp;nbsp;macro variable for the grp_lst &amp;nbsp;- your 'original_list' from my dataset drug1 . I was then trying to go variable by variable to count the levels in a sample dataset (drug1) &amp;nbsp;and if that count was less than the EXPECTED count of that same variable, I would ideally remove it from the list. I see that I was trying to mix macro and real variables which was a problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alos, I call out the individual items in the list by using the %scan(&amp;amp;var_lst, &amp;amp;k.) in a %DO loop so i'd rather not&amp;nbsp;introduce more macro variables as your second proc sql does if I can avoid it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 17:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376666#M90426</guid>
      <dc:creator>CP2</dc:creator>
      <dc:date>2017-07-17T17:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376669#M90428</link>
      <description>&lt;P&gt;I have to use the % because my code is within a macro.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 17:53:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376669#M90428</guid>
      <dc:creator>CP2</dc:creator>
      <dc:date>2017-07-17T17:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376672#M90430</link>
      <description>&lt;P&gt;The %do does not belong in this data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want to use the data step DO command.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 17:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376672#M90430</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-07-17T17:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376673#M90431</link>
      <description>&lt;P&gt;actually, I don't need the %. thanks&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 17:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376673#M90431</guid>
      <dc:creator>CP2</dc:creator>
      <dc:date>2017-07-17T17:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376675#M90432</link>
      <description>&lt;P&gt;We can work with your names, if you would prefer.&amp;nbsp; Just based on personal preference, I chose a style that I find easier to read.&amp;nbsp; For example, I actually created macro variables without the "_lvl" at the end, holding the same values as your _lvl versions.&amp;nbsp; But it's no problem using your names.&amp;nbsp; Here's the idea for the next step, constructing a list of those that should be removed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let to_be_removed=;&lt;/P&gt;
&lt;P&gt;%do k=1 %to &amp;amp;varCount;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if %scan(&amp;amp;var_lst, &amp;amp;k)_lvl &amp;lt; %scan(&amp;amp;expected, &amp;amp;k) %then %let to_be_removed = &amp;amp;to_be_removed %scan(&amp;amp;var_lst, &amp;amp;k);&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take a look, and confirm that you're getting the list of variables that don't have enough levels.&amp;nbsp; That doesn't remove them from the original list, but it does isolate the names of those that should be removed.&amp;nbsp;&amp;nbsp; So another step will follow.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 18:03:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376675#M90432</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-17T18:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376679#M90433</link>
      <description>&lt;P&gt;So removing the %s helped but the tranwrd is not working. can you see what I am doing wrong with the tranwrd command? the last line is from a put statement but clearly based on the values grp_name should only be age.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MPRINT(SURROGATE): DATA drug1 ;&lt;BR /&gt;MPRINT(SURROGATE): SET drug1 ;&lt;BR /&gt;MPRINT(SURROGATE): ARRAY var_lst[ 4] AGE GENDER TYPE1 TYPE2&amp;nbsp;;&lt;BR /&gt;MPRINT(SURROGATE): array act{ 4} (3 2 2 5) ;&lt;BR /&gt;MPRINT(SURROGATE): array exp{ 4} (3 3 3 6 );&lt;BR /&gt;MPRINT(SURROGATE): do j = 1 to 4 ;&lt;BR /&gt;MPRINT(SURROGATE): if act[j] &amp;lt; exp[j] then grp_lst = tranwrd(grp_lst, var_lst[j], " " ) ;&lt;BR /&gt;MPRINT(SURROGATE): end ;&lt;BR /&gt;MPRINT(SURROGATE): run ;&lt;/P&gt;&lt;P&gt;NOTE: There were 19540 observations read from the data set WORK.DRUG1.&lt;BR /&gt;NOTE: The data set WORK.DRUG1 has 19540 observations and 26 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.04 seconds&lt;BR /&gt;cpu time 0.04 seconds&lt;/P&gt;&lt;P&gt;MPRINT(SURROGATE): data _null_;&lt;BR /&gt;MPRINT(SURROGATE): set drug1 (obs=1);&lt;BR /&gt;MPRINT(SURROGATE): call symputx('grp_name' , grp_lst);&lt;BR /&gt;MPRINT(SURROGATE): run;&lt;/P&gt;&lt;P&gt;NOTE: There were 1 observations read from the data set WORK.DRUG1.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;BR /&gt;&lt;BR /&gt;17 The SAS System 10:44 Monday, July 17, 2017&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;grp_name = age gender type1&amp;nbsp;type2&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 18:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376679#M90433</guid>
      <dc:creator>CP2</dc:creator>
      <dc:date>2017-07-17T18:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376684#M90435</link>
      <description>&lt;P&gt;Would help if you provide an example drug1 file&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 18:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376684#M90435</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-17T18:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376685#M90436</link>
      <description>&lt;P&gt;ok. can you back up a bit. what is the best way to get the value counts from drug1 assuming we know the var_lst ? your second proc sql from your original post is creating separate variable. Is there quick step to get a list of values from separate variables? I&amp;nbsp;got the list for the expected values but it took a few steps to get each value then concatenate them into a column and then used proc sql with into: to get the list. Originally when I got to the step where I needed to determine the condition (actual &amp;lt; expected) I was getting the actual variable by variable. Your newest proc sql sounds like what I need but I first need to get the full list of actuals.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 18:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376685#M90436</guid>
      <dc:creator>CP2</dc:creator>
      <dc:date>2017-07-17T18:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376693#M90440</link>
      <description>&lt;P&gt;I'm not certain that creating a list of actual values is necessary.&amp;nbsp; But if it is, here is a way it can be done.&amp;nbsp; Assuming that macro variables already exist as detailed earlier (&amp;amp;VARCount=3, &amp;amp;VAR_LST=age gender type, plus &amp;amp;AGE, &amp;amp;GENDER, and &amp;amp;TYPE holding actual counts):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%local actual_counts;&lt;/P&gt;
&lt;P&gt;%do k=1 %to &amp;amp;varCount;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %let next_name = %scan(&amp;amp;var_lst, &amp;amp;k);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %let actual_counts = &amp;amp;actual_counts &amp;amp;&amp;amp;&amp;amp;next_name;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 18:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376693#M90440</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-17T18:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376696#M90442</link>
      <description>&lt;P&gt;The grp_lst probably should have been done all in macro language but I couldn't figure that out so I created a column that I later put into a macro list using proc sql into; &amp;nbsp;So, now that I have this I am trying to work with it . If I can edit the column using tranwrd then I will eventually create a macro list from it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is a brief sample. Basicall, grp_lst is the same for each drug in the database when I loop through drugs I use a new list for each drug. This sample is for just drug1 .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data drug1_sample ;&lt;BR /&gt;length grp_lst $32. ;&lt;BR /&gt;input drug $ age $ gender $ type1 $ type2 $ grp_lst $ ;&lt;BR /&gt;infile datalines4 delimiter=',' ;&lt;BR /&gt;datalines;&lt;BR /&gt;drug1,&amp;lt;50,F,A,B,age gender type1 type2&lt;BR /&gt;drug1,&amp;lt;50,F,B,B,age gender type1 type2&lt;BR /&gt;drug1,&amp;lt;50,F,C,B,age gender type1 type2&lt;BR /&gt;drug1,&amp;lt;50,M,A,B,age gender type1 type2&lt;BR /&gt;drug1,&amp;lt;50,M,B,B,age gender type1 type2&lt;BR /&gt;drug1,&amp;lt;50,M,C,B,age gender type1 type2&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc print ;run;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 18:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376696#M90442</guid>
      <dc:creator>CP2</dc:creator>
      <dc:date>2017-07-17T18:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376705#M90445</link>
      <description>&lt;P&gt;only the expected variable list and expected values exist (the actual variable list starts out equal to the expected variable list in this example). The actual number of distinct values/levels for each variable in the drug1 dataset needs to be created. If a condition is met (actual &amp;lt; expected) for that variable then the associated variable needs to be removed from the original list.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 18:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376705#M90445</guid>
      <dc:creator>CP2</dc:creator>
      <dc:date>2017-07-17T18:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: resolving macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376722#M90453</link>
      <description>&lt;P&gt;Here's an approach that skips part of the list creation.&amp;nbsp; It builds a smaller list ... just those variable names that have actual values less than expected values.&amp;nbsp; Start with your original 3&amp;nbsp;%LET statements.&amp;nbsp; Then ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%local less_than_expected;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %do k=1 %to &amp;amp;varCount;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;select count(distinct %scan(&amp;amp;var_lst, &amp;amp;k)) into : actual from drug1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;actual &amp;lt; %scan(&amp;amp;expected, &amp;amp;k) %then %let less_than_expected = &amp;amp;less_than_expected %scan(&amp;amp;var_lst, &amp;amp;k);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if I'm helping by showing this or not.&amp;nbsp; Basically, the SELECT statement in SQL executes immediately, and so &amp;amp;ACTUAL is immediately available for use in the next statement.&amp;nbsp; It doesn't work that way when you switch from SQL to a DATA step, however.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are we getting closer to the target here?&amp;nbsp; I realize we still need to utilize &amp;amp;LESS_THAN_EXPECTED.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 19:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/resolving-macro/m-p/376722#M90453</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-17T19:30:04Z</dc:date>
    </item>
  </channel>
</rss>

