<?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 How to write a code in this situation. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-write-a-code-in-this-situation/m-p/559160#M10248</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on multiple clinical trials and I am using single program for all these individual trial. I came across with the situation where I need to derive 10 variables using X dataset for all the 3 trials. but unfortunately for one trial I need to derive all these 10 variables using Y dataset. The&amp;nbsp;variables I need to use to derive all these 10 new variables in the dataset X &amp;amp; Y are same but only difference is the dataset names X &amp;amp; Y. How can I write this in a single piece of code to select Y dataset for one trial else select X dataset for other two trials.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the below code but it is giving me the observations from the second dataset only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;&lt;I&gt;fa&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;study = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;Trial c&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;data fmh;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;srcdata.&lt;STRONG&gt;.f&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;a;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;data fmh;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;srcdata.&lt;STRONG&gt;.f&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;amh;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;fa&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all your time.&lt;/P&gt;</description>
    <pubDate>Wed, 15 May 2019 20:57:09 GMT</pubDate>
    <dc:creator>ramtejdasari</dc:creator>
    <dc:date>2019-05-15T20:57:09Z</dc:date>
    <item>
      <title>How to write a code in this situation.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-write-a-code-in-this-situation/m-p/559160#M10248</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on multiple clinical trials and I am using single program for all these individual trial. I came across with the situation where I need to derive 10 variables using X dataset for all the 3 trials. but unfortunately for one trial I need to derive all these 10 variables using Y dataset. The&amp;nbsp;variables I need to use to derive all these 10 new variables in the dataset X &amp;amp; Y are same but only difference is the dataset names X &amp;amp; Y. How can I write this in a single piece of code to select Y dataset for one trial else select X dataset for other two trials.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the below code but it is giving me the observations from the second dataset only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;&lt;I&gt;fa&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;study = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%str&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;Trial c&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;data fmh;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;srcdata.&lt;STRONG&gt;.f&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;a;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%else&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;data fmh;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set &amp;amp;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;srcdata.&lt;STRONG&gt;.f&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;amh;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;fa&lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all your time.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 20:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-write-a-code-in-this-situation/m-p/559160#M10248</guid>
      <dc:creator>ramtejdasari</dc:creator>
      <dc:date>2019-05-15T20:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a code in this situation.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-write-a-code-in-this-situation/m-p/559168#M10249</link>
      <description>&lt;P&gt;Where do you set the value for &amp;amp;study? Your comparison is case sensitive so if you set &amp;amp;study with something like : %let study=Trial C;&lt;/P&gt;
&lt;P&gt;it would not match the value Trial c&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Source and value for &amp;amp;srcdata?&lt;/P&gt;
&lt;P&gt;If &amp;amp;srcdata is not a library then your data reference is incorrect. If it already contains a library.dataset then you do not want the second .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let srcdata=work.data;
%let setname = &amp;amp;srcdata..famh;
/*invalid data set name*/
%put setname is &amp;amp;setname.;

%let srcdata=dataset;
%let setname = &amp;amp;srcdata..famh;
/*treats what might be data set name as library*/
%put setname is &amp;amp;setname.;


&lt;/PRE&gt;
&lt;P&gt;In general it is not best practice to use values in macro code not explicitly passed as parameters. Your code call does not document the expected values sent to the macro&amp;nbsp;with something like %fa&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would be better off using %macro fa (study= , srcdata= ); in the definition and then call as&lt;/P&gt;
&lt;P&gt;%fa(study=x, srcdata=lib); or what ever values are being used.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 21:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-write-a-code-in-this-situation/m-p/559168#M10249</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-15T21:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a code in this situation.</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-write-a-code-in-this-situation/m-p/559178#M10251</link>
      <description>&lt;P&gt;Hi Ballardw&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;we have a separate program like studyauto , where we created macro variables for study and srcdata.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just tried the code by removing %str in the code and it works now.it is related to the &amp;amp;study variable in the studyauto program where we created this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again thank you so much for your valuable input. It resolved now.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 21:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-write-a-code-in-this-situation/m-p/559178#M10251</guid>
      <dc:creator>ramtejdasari</dc:creator>
      <dc:date>2019-05-15T21:42:47Z</dc:date>
    </item>
  </channel>
</rss>

