<?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: How do I create a macro variable that is based on the values of another macro variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-macro-variable-that-is-based-on-the-values-of/m-p/484105#M125624</link>
    <description>&lt;P&gt;Why do you want to put these into macro variables? What are you going to do with them?&lt;/P&gt;</description>
    <pubDate>Sun, 05 Aug 2018 06:01:51 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-08-05T06:01:51Z</dc:date>
    <item>
      <title>How do I create a macro variable that is based on the values of another macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-macro-variable-that-is-based-on-the-values-of/m-p/482963#M125178</link>
      <description>&lt;P&gt;Hi, new SAS programmer here. The data I have currently looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;State | User_ID | Year | Month&lt;/P&gt;&lt;P&gt;OH&amp;nbsp; &amp;nbsp; | A122&amp;nbsp; &amp;nbsp; &amp;nbsp; | 2006 | 1&lt;/P&gt;&lt;P&gt;OH&amp;nbsp; &amp;nbsp; | A122&amp;nbsp; &amp;nbsp; &amp;nbsp; | 2006 | 2&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;OH&amp;nbsp; &amp;nbsp; | A321&amp;nbsp; &amp;nbsp; &amp;nbsp; | 2006 | 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;AL&amp;nbsp;&amp;nbsp; &amp;nbsp; | A423&amp;nbsp; &amp;nbsp; &amp;nbsp; | 2007 | 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;AK&amp;nbsp; &amp;nbsp;&amp;nbsp; | A532&amp;nbsp; &amp;nbsp; &amp;nbsp;| 2006 | 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I need to create macro variables for distinct User_IDs as well as their corresponding states. The code I have for this currently looks like this:&lt;/SPAN&gt;&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;proc sql;
	select 			count(distinct User_ID)
	into 		    :NObs
	from 			have;
	select distinct User_ID
	into 		    :customer1-:customer%left(&amp;amp;NObs)
	from 			have;
    select          State
	into 		    :states
	from 	        have;
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem with this is that since there are multiple distinct User_IDs per State, the macro variable for state has far more values than the macro variable for User_ID. What I need here is to have a macro variable for State that has the corresponding state value for each User_ID. For example, customer1=A122 so state1=OH; customer2=A321 so state2=OH; customer3=A423 so state3=AL, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There could be customers with the same User_ID but belong to different states which is why I am trying to create the macro variable for State. However, within a state, all User_IDs are the same customer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jul 2018 22:50:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-macro-variable-that-is-based-on-the-values-of/m-p/482963#M125178</guid>
      <dc:creator>Ani7</dc:creator>
      <dc:date>2018-07-31T22:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a macro variable that is based on the values of another macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-macro-variable-that-is-based-on-the-values-of/m-p/484104#M125623</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;why dont we remove the distinct from the below code, it should get you the expected result

proc sql;
	select 			count(User_ID)
	into 		    :NObs
	from 			have;
	select distinct User_ID
	into 		    :customer1-:customer%left(&amp;amp;NObs)
	from 			have;
    select          State
	into 		    :states
	from 	        have;
	;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Aug 2018 05:49:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-macro-variable-that-is-based-on-the-values-of/m-p/484104#M125623</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-08-05T05:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a macro variable that is based on the values of another macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-macro-variable-that-is-based-on-the-values-of/m-p/484105#M125624</link>
      <description>&lt;P&gt;Why do you want to put these into macro variables? What are you going to do with them?&lt;/P&gt;</description>
      <pubDate>Sun, 05 Aug 2018 06:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-macro-variable-that-is-based-on-the-values-of/m-p/484105#M125624</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-08-05T06:01:51Z</dc:date>
    </item>
  </channel>
</rss>

