<?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: i have a dataset and i need to create macro variable for 2 values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350851#M81619</link>
    <description>&lt;P&gt;i ran it and infact N values are getting resolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i renamed the variable name to armcd and it has values dummy1 and dummy2&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set dummy_freq ;&lt;BR /&gt;call symputx(cats('armcd',_n_),armcd);&lt;BR /&gt;call symputx(cats('n',_n_),frequency);&lt;BR /&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and in next datastep i am using&lt;/P&gt;&lt;P&gt;treatGrp = "&amp;amp;trt1 versus &amp;amp;trt2";&lt;/P&gt;&lt;P&gt;label esti="Slope: &amp;amp;trt1 (N=&amp;amp;n1) versus &amp;amp;trt2 (N=&amp;amp;n2)" ;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Apr 2017 13:45:40 GMT</pubDate>
    <dc:creator>alexdsa310</dc:creator>
    <dc:date>2017-04-18T13:45:40Z</dc:date>
    <item>
      <title>i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350777#M81581</link>
      <description>&lt;P&gt;i have a dataset and i need to create macro variable for 2 values. trt and freq&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;trt&lt;/TD&gt;&lt;TD&gt;freq&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;trt1&lt;/TD&gt;&lt;TD&gt;27&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;trt2&lt;/TD&gt;&lt;TD&gt;28&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can i create macro variable for trt and freq so that i can use in outputs which i need like trt1 vs trt2 and&lt;/P&gt;&lt;P&gt;trt1(N=27) versus trt2 (N=28).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;currently i hardcode it in my program&amp;nbsp;treatGrp = "trt1 (N=27) versus trt2&amp;nbsp;(N=28)"; and&amp;nbsp;esti="Slope: trt1 vs, trt2"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any help or if it is not clear in my explanation&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 11:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350777#M81581</guid>
      <dc:creator>alexdsa310</dc:creator>
      <dc:date>2017-04-18T11:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350778#M81582</link>
      <description>&lt;P&gt;I'm a little confused. Are you trying to set the macro variable values using the results of proc freq?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 11:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350778#M81582</guid>
      <dc:creator>jessicaking</dc:creator>
      <dc:date>2017-04-18T11:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350780#M81583</link>
      <description>&lt;P&gt;yes i want to set values and use them for ex:&lt;/P&gt;&lt;P&gt;in my trt i have values trt1 and trt2 instead of hard coding i want to macrovise it and use and the same with values&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 11:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350780#M81583</guid>
      <dc:creator>alexdsa310</dc:creator>
      <dc:date>2017-04-18T11:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350787#M81586</link>
      <description>&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;proc sql noprint;
  select count(distinct SUBJECT) into: TRT1 from ADSL where TRT="TRT A";
  select count(distinct SUBJECT) into: TRT2 from ADSL where TRT="TRT B";
quit;

proc report...;
  define trta / "Treatment (N=%trim(&amp;amp;TRT1.))";
...
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Apr 2017 11:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350787#M81586</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-18T11:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350789#M81588</link>
      <description>&lt;P&gt;Thanks, but there is a problem in it because the trt1 and trt2 will be changed later to soem other treatment arm.&lt;/P&gt;&lt;P&gt;That is the reason i am concerned how to make it automatically&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 11:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350789#M81588</guid>
      <dc:creator>alexdsa310</dc:creator>
      <dc:date>2017-04-18T11:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350793#M81590</link>
      <description>&lt;P&gt;So you have a summary for number of patients by treatment.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input trt $ freq ;
cards;
trtA 27
trtB 28
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And you want to create macro variables TRT1, TRT2, ....&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have ;
  call symputx(cats('trt',_n_),catx(' ',trt,cats('(N=',put(freq,comma16.),')')));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Apr 2017 12:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350793#M81590</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-18T12:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350799#M81593</link>
      <description>&lt;P&gt;Thanks Tom ,&lt;/P&gt;&lt;P&gt;Can you please let me know how to use it in my hardcoded current step&lt;/P&gt;&lt;P&gt;treatGrp = "trt11 (N=27) versus trt2&amp;nbsp;(N=28)";&lt;/P&gt;&lt;P&gt;label &amp;nbsp; &amp;nbsp; &amp;nbsp;esti="Slope: trt1 vs. trt2" &amp;nbsp;in datastep.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 12:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350799#M81593</guid>
      <dc:creator>alexdsa310</dc:creator>
      <dc:date>2017-04-18T12:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350827#M81609</link>
      <description>&lt;P&gt;You can expand the macro variables where you need them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;treatGrp = "&amp;amp;trt1 versus &amp;amp;trt2";
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use macro functions on them if you need.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;label
  esti="Slope: %scan(&amp;amp;trt1,1,()) vs. %scan(&amp;amp;trt2,1,())"
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Apr 2017 13:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350827#M81609</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-18T13:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350829#M81610</link>
      <description>&lt;P&gt;Sorry Tom for not catching you as i am new to these things.&lt;/P&gt;&lt;P&gt;I get warnings if i do and macro is not resolved&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference TRT1 not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference TRT2 not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference TRT1 not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference TRT1 not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference TRT2 not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference TRT1 not resolved.&lt;BR /&gt;WARNING: Apparent symbolic reference TRT2 not resolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it something to do with the below&lt;/P&gt;&lt;P&gt;call symputx(cats('trt',_n_),catx(' ',trt,cats('(N=',put(freq,comma16.),')')));&lt;/P&gt;&lt;P&gt;as i am not mentioning anything here about trt1 and trt2 which are treatment arms and may change later&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 13:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350829#M81610</guid>
      <dc:creator>alexdsa310</dc:creator>
      <dc:date>2017-04-18T13:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350830#M81611</link>
      <description>&lt;P&gt;There is no "automatic creation of treatment populations" button or code. &amp;nbsp;Each study will be different as described in the protocol, hence you will need to setup each study per the protocol. &amp;nbsp;For instance there may be crossover designs. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit, just to add, I assume this is across studies as its not very often that treatment arms change, and if they do then that requires protocol/SAP etc. updates which would include updating the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 13:13:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350830#M81611</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-18T13:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350839#M81614</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make it easier to code the NAMES of the macro variables shouldn't change. It is the VALUE of the macro variable that will change.&lt;/P&gt;
&lt;P&gt;But you can't use the macro variables before you have created them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you said you had a dataset with two observations which had treatment label and count. I showed you a method to convert those two observations into two macro variables in the format you requested.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have ;
  call symputx(cats('trt',_n_),catx(' ',trt,cats('(N=',put(freq,comma16.),')')));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You then showed an example of where you wanted to use the macro variables in later code and I showed you how to use the macro variable value directly and also one of many ways that you can use macro functions to operate on the value of the macro variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data  ...
  ... 
  treatGrp = "&amp;amp;trt1 versus &amp;amp;trt2";
  label
    esti="Slope: %scan(&amp;amp;trt1,1,()) vs. %scan(&amp;amp;trt2,1,())"
  ;
  ...
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Perhaps it would be easier to create four macro variables?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have ;
  call symputx(cats('trt',_n_),trt);
  call symputx(cats('n',_n_),freq);
run;

data  ...
  ... 
  treatGrp = "&amp;amp;trt1 (N=&amp;amp;n1) versus &amp;amp;trt2 (N=&amp;amp;n2)";
  label
    esti="Slope: &amp;amp;trt1 vs. &amp;amp;trt2"
  ;
  ...
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Apr 2017 13:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350839#M81614</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-18T13:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350846#M81616</link>
      <description>&lt;P&gt;unfortunately trt1 and trt2 are not getting resolved &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Do i need to create them as macro variables like&lt;/P&gt;&lt;P&gt;%macro ttd (trt1=,trt2=);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 13:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350846#M81616</guid>
      <dc:creator>alexdsa310</dc:creator>
      <dc:date>2017-04-18T13:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350849#M81618</link>
      <description>&lt;P&gt;The CALL SYMPUTX() statements will create the macro variables. &amp;nbsp;If they did not get created either you did not run that data step or you ran it on an empty input dataset so that the CALL SYMPUTX() statements never ran.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 13:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350849#M81618</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-18T13:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350851#M81619</link>
      <description>&lt;P&gt;i ran it and infact N values are getting resolved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i renamed the variable name to armcd and it has values dummy1 and dummy2&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set dummy_freq ;&lt;BR /&gt;call symputx(cats('armcd',_n_),armcd);&lt;BR /&gt;call symputx(cats('n',_n_),frequency);&lt;BR /&gt;run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and in next datastep i am using&lt;/P&gt;&lt;P&gt;treatGrp = "&amp;amp;trt1 versus &amp;amp;trt2";&lt;/P&gt;&lt;P&gt;label esti="Slope: &amp;amp;trt1 (N=&amp;amp;n1) versus &amp;amp;trt2 (N=&amp;amp;n2)" ;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 13:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350851#M81619</guid>
      <dc:creator>alexdsa310</dc:creator>
      <dc:date>2017-04-18T13:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: i have a dataset and i need to create macro variable for 2 values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350852#M81620</link>
      <description>&lt;P&gt;You did not create macro variable TRT1 or TRT2. Your code would have create macro variables named ARMCD1 and ARMCD2.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 13:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/i-have-a-dataset-and-i-need-to-create-macro-variable-for-2/m-p/350852#M81620</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-18T13:47:43Z</dc:date>
    </item>
  </channel>
</rss>

