<?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: Macro to name datasets in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Macro-to-name-datasets/m-p/533385#M6173</link>
    <description>I don't see any particular issues with your code, besides where you've added the ISSUE note. Does the log indicate any error? What happens if you try to run a proc contents on the data set? Or use it in a future step?</description>
    <pubDate>Wed, 06 Feb 2019 20:32:49 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-02-06T20:32:49Z</dc:date>
    <item>
      <title>Macro to name datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-to-name-datasets/m-p/533378#M6171</link>
      <description>&lt;P&gt;I am using enterprise guide 7.1 and sas 9.4.&lt;/P&gt;
&lt;P&gt;I am trying to name datasets based on the type of information in them, mainly the group that they belong to. 5 day 30 day 60 day etc. When it gets to the naming part, the datasets show up in the output data section, but if you try to open them they are not there.&amp;nbsp; Any help is appreciated.&amp;nbsp; Thank you for your time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro tock (seg,dset);

	data quick;
		format rpc_pct percent8.2;
		set finished;

		if segment eq &amp;amp;seg;
		rpc_pct = contact/attempt;
	RUN;

	proc sort data= quick;
		by descending rpc_pct;
	RUN;

	data quick;
		format rpc_rank 8.;
		set quick;

		if first.rpc_pct then
			rpc_rank= 0;
		rpc_rank + 1;
	RUN;

	proc sort data= quick;
		by descending cev;
	RUN;

	data quick2;
		format cev_rank 8. overall_rank 8.2;
		set quick;

		if first.cev then
			cev_rank =0;
		cev_rank +1;
		overall_rank=((0.8*cev_rank)+(.2*rpc_rank));
		group = missing(overall_rank);
	RUN;

	proc sort data= quick2;
		by group overall_rank;
	RUN;

	proc rank data=quick2 out=finalquick groups=4;
		var overall_rank;
		ranks tier;
	RUN;

	data finalquick;
		retain primekey agency segment tenure employeecode employeename attempt contact promise kept

			PromiseRate KeptRate CEV avgpay colldollars mean_cev std_cev rpc_pct rpc_rank

			cev_rank overall_rank tier;
		set finalquick;

		if tier = 3 then
			tier =4;
		else if tier = 2 then
			tier=3;
		else if tier = 1 then
			tier=2;
		else if tier = 0 then
			tier=1;
		keep primekey agency segment tenure employeecode employeename attempt contact promise kept

			PromiseRate KeptRate CEV avgpay colldollars mean_cev std_cev rpc_pct rpc_rank

			cev_rank overall_rank tier;
	RUN;

ISSUE:

	data _&amp;amp;dset.;
		set finalquick;
	RUN;

%mend;

%tock('5-Day','fiveday');
%tock('30-Day','thirtyday');&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 20:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-to-name-datasets/m-p/533378#M6171</guid>
      <dc:creator>pangea17</dc:creator>
      <dc:date>2019-02-06T20:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to name datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-to-name-datasets/m-p/533384#M6172</link>
      <description>&lt;P&gt;By putting quotes around the value you passed to the macro you confused SAS into thinking you meant to create two datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See this example:&lt;/P&gt;
&lt;PRE&gt;237   data _'First';
238    set sashelp.class;
239   run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK._ has 19 observations and 5 variables.
NOTE: The data set First has 19 observations and 5 variables.
&lt;/PRE&gt;
&lt;P&gt;So it made one dataset named WORK._ and it made the other dataset in the current working directory of the process that is running the SAS code since the quoted physical name did not include any other directory information.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To the macro processor quotes are just part of the value.&amp;nbsp; Remove them in your call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro tock (seg,dset);
...
if segment eq &amp;amp;seg;
...
data _&amp;amp;dset.;
...
%mend;

%tock('5-Day',fiveday);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that the value of SEG needs the quotes because the quotes are important in the SAS code that the macro is generating.&amp;nbsp; SAS needs the quotes to be able to distinguish between a string constant and a variable name or number.&amp;nbsp; The macro processor does not need quotes for this. To the macro processor everything is just text. It only needs to look for &amp;amp; or % triggers to see if it needs to process the strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 20:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-to-name-datasets/m-p/533384#M6172</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-06T20:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to name datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Macro-to-name-datasets/m-p/533385#M6173</link>
      <description>I don't see any particular issues with your code, besides where you've added the ISSUE note. Does the log indicate any error? What happens if you try to run a proc contents on the data set? Or use it in a future step?</description>
      <pubDate>Wed, 06 Feb 2019 20:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Macro-to-name-datasets/m-p/533385#M6173</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-06T20:32:49Z</dc:date>
    </item>
  </channel>
</rss>

