<?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: Proc Sql Create Table Error in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/322434#M62018</link>
    <description>&lt;P&gt;Hi Laurie,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sorry for the late reply, with holiday travel etc I got a bit behind on things. Hope you had a great New Year!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm SO SORRY. &amp;nbsp;Thank you so much for correcting me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on your code, I formulated the code below, which works for me. &amp;nbsp;However, there are some small problems:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* program for creating enrollment table*/
%let date=20170102;
%let datebegin = %sysevalf('26dec2016'd);
%let dateend = %sysevalf('02jan2017'd);
/*import csv*/
 proc import out=work.enrollmentbysubject datafile="Z:\ADAPTABLE\Mytrus\Pickups from Mytrus\&amp;amp;date.\enrollmentbysubject.csv" 
		dbms=csv replace;
	getnames=yes;
	datarow=2;
	guessingrows=20000;
run;

data work.enrollmentbysubject;
	set work.enrollmentbysubject;
	if compress(cats(CDRN), '.')=' ' then
		delete;
run;
/*convert datetimes in column "Randomized" to SAS datetimes*/
data work.enrollmentbysubject;
	set work.enrollmentbysubject;
	Randomized_date = datepart(input(Randomized, anydtdtm23.));
    format Randomized_date yymmdds10.;
run;
/*create table that I want*/
proc sql noprint feedback;
create table work.dailyenrollmenttable_&amp;amp;date. AS
	select distinct cdrn, site,
           count(Invitation_Code_Used) AS Golden_Tickets_Entered,
           count(Randomized) AS Enrolled,
           (calculated enrolled / calculated golden_tickets_entered) as percent_enrolled format=percent8.2
	from work.enrollmentbysubject
	 Group by site;
quit;
proc sql noprint feedback;
create table work.patientsenrolledperweek_&amp;amp;date. AS
select distinct cdrn, site, count(Randomized_date) AS Patients_Enrolled_Per_week
from work.enrollmentbysubject
where Randomized_date between &amp;amp;datebegin and &amp;amp;dateend
group by site;
quit;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) if I move the below statements into my first proc sql statement, then the table that is returned just has the patients enrolled per week. &amp;nbsp;Meaning, for example Penn St has 88 Golden Tickets Entered, 28 enrolled, and 31.82% enrolled. &amp;nbsp;But if I add the Patients_Enrolled_Per Week column it will put that value in all of the columns. &amp;nbsp;Do you know why this is? So the way I got around that was just by making 2 separate tables and than manually inputting the "patients enrolled per week" into the other table. &amp;nbsp;Doesn't seem like the most efficient thing in the world...&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;count(Randomized_date) AS Patients_Enrolled_Per_week&lt;BR /&gt;&lt;BR /&gt;where Randomized_date between &amp;amp;datebegin and &amp;amp;dateend&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Lets say for discussion purposes, that I have 15 sites that I'm gathering enrollment data for (meaning 15 rows in my table). &amp;nbsp;If one site, say Montefiore Medical Center, does not enroll any patients that week, how do I populate the Patients_Enrolled_Per_Week table with a "0". &amp;nbsp;Right now it only is showing me sites that do have a positive count.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) In your code below, I don't really understand the point of your&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;ranuni&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;225465114&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;5&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt;
   invitation_code_used &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Y'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;in your data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for helping me out with this, you've been a lifesaver!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pete&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jan 2017 16:13:23 GMT</pubDate>
    <dc:creator>pkantak</dc:creator>
    <dc:date>2017-01-04T16:13:23Z</dc:date>
    <item>
      <title>Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321371#M61953</link>
      <description>&lt;P&gt;Hi SAS Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to create a table which has various columns including a column (Patients_Enrolled_Per_Week) that consists of a count of another column that is constrained between two date macrovariables (datebegin &amp;amp; dateend). &amp;nbsp;I'm getting an error which I'll post below. &amp;nbsp;I've been trying to figure out why this is happening but I'm stumped. &amp;nbsp;I'm attaching my code, the error, and an example of what I want my data to look like. &amp;nbsp;Please let me know if you have answers! I'm at my wit's end!!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks much!!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Pete&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;/* program for creating enrollment table*/
%let date=20161218;
%let datebegin=12/19/2016;
%let dateend=12/22/2016;
/*import csv*/
 proc import out=work.enrollmentbysubject datafile="Z:\ADAPTABLE\Mytrus\Pickups from Mytrus\&amp;amp;date.\enrollmentbysubject.csv" 
		dbms=csv replace;
	getnames=yes;
	datarow=2;
	guessingrows=20000;
run;
/*delete space in CDRN column*/
data work.enrollmentbysubject;
	set work.enrollmentbysubject;
	if compress(cats(CDRN), '.')=' ' then
		delete;
run;
/*convert datetimes in column "Randomized" to SAS datetimes*/
data work.temp; set work.enrollmentbysubject;
Randomized_num=input(Randomized,anydtdtm23.);
Format Randomized_num DateTime23.3;
run;
/*separate SAS datetime to SAS date with format MM/DD/YYYY*/
data work.temp2; set work.temp;
Randomized_Date=datepart(Randomized_num);
Format Randomized_date MMDDYYS10.;
run;
/*create table that I want*/
proc sql noprint feedback;
create table work.dailyenrollmenttable_&amp;amp;date. AS
	select distinct cdrn, site,
/*count of Golden Tickets entered*/
(count(Invitation_Code_Used)) AS Golden_Tickets_Entered,
/*count of Randomized Patients*/
(count(Randomized)) AS Enrolled,
/*percentage enrolled per golden ticket entered*/
(Count(Randomized)) / (Count(Invitation_Code_Used)) AS Percent_Enrolled format percent8.2,
/*number of enrolled patients per week*/
(count(Randomized_date)) AS Patients_Enrolled_Per_week
from Work.temp2
where Randomized_date between "&amp;amp;datebegin." and "&amp;amp;dateend."
Group By site;
quit;&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;Error Message:&lt;/P&gt;&lt;P&gt;690 proc sql noprint feedback;&lt;BR /&gt;691 create table work.dailyenrollmenttable_&amp;amp;date. AS&lt;BR /&gt;692 select distinct cdrn, site,&lt;BR /&gt;693 /*count of Golden Tickets entered*/&lt;BR /&gt;694 (count(Invitation_Code_Used)) AS Golden_Tickets_Entered,&lt;BR /&gt;695 /*count of Randomized Patients*/&lt;BR /&gt;696 (count(Randomized)) AS Enrolled,&lt;BR /&gt;697 /*percentage enrolled per golden ticket entered*/&lt;BR /&gt;698 (Count(Randomized)) / (Count(Invitation_Code_Used)) AS Percent_Enrolled format percent8.2,&lt;BR /&gt;699 /*number of enrolled patients per week*/&lt;BR /&gt;700 (count(Randomized_date)) AS Patients_Enrolled_Per_week&lt;BR /&gt;701 from Work.temp2&lt;BR /&gt;702 where Randomized_date between "&amp;amp;datebegin." and "&amp;amp;dateend."&lt;BR /&gt;703 Group By site;&lt;BR /&gt;ERROR: Expression using IN has components that are of different data types.&lt;BR /&gt;NOTE: The IN referred to may have been transformed from an OR to an IN at some point during&lt;BR /&gt;PROC SQL WHERE clause optimization.&lt;BR /&gt;NOTE: Statement transforms to:&lt;/P&gt;&lt;P&gt;select distinct TEMP2.CDRN, TEMP2.Site, COUNT(TEMP2.Invitation_Code_Used) as&lt;BR /&gt;Golden_Tickets_Entered, COUNT(TEMP2.Randomized) as Enrolled, COUNT(TEMP2.Randomized) /&lt;BR /&gt;COUNT(TEMP2.Invitation_Code_Used) as Percent_Enrolled format=PERCENT8.2,&lt;BR /&gt;COUNT(TEMP2.Randomized_Date) as Patients_Enrolled_Per_week&lt;BR /&gt;from WORK.TEMP2&lt;BR /&gt;where (TEMP2.Randomized_Date between '12/19/2016' and '12/22/2016')&lt;BR /&gt;group by TEMP2.Site;&lt;/P&gt;&lt;P&gt;704 quit;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&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;&lt;P&gt;Example Desired Output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Site ID&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;CDRN&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Site&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Golden Tickets Entered&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Enrolled&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;% Enrolled Per Golden Ticket Entered&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;# Enrolled (12/19/16-12/27/16)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;A1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;CDRN1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Site1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1000&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;700&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;70%&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;A2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;CDRN2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Site2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2000&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1000&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;50%&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 28 Dec 2016 02:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321371#M61953</guid>
      <dc:creator>pkantak</dc:creator>
      <dc:date>2016-12-28T02:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321381#M61954</link>
      <description>&lt;P&gt;Your sql has generated the expression&lt;/P&gt;
&lt;P&gt;&amp;nbsp; where (TEMP2.Randomized_Date between '12/19/2016' and '12/22/2016')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But randommised_date is numeric and the limits are character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Redefine your macrovars to:&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token macroname"&gt;&amp;nbsp;&amp;nbsp; %let&lt;/SPAN&gt; datebegin&lt;SPAN class="token operator"&gt;=19dec2016&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token macroname"&gt;&amp;nbsp;&amp;nbsp; %let&lt;/SPAN&gt; dateend&lt;SPAN class="token operator"&gt;=22dec2016;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token operator"&gt;Then change your code from&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token operator"&gt;&lt;SPAN class="token statement"&gt;&amp;nbsp; where&lt;/SPAN&gt; Randomized_date between &lt;SPAN class="token string"&gt;"&amp;amp;datebegin."&lt;/SPAN&gt; and &lt;SPAN class="token string"&gt;"&amp;amp;dateend."&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token operator"&gt;&lt;SPAN class="token string"&gt;to&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token operator"&gt;&lt;SPAN class="token string"&gt;&lt;SPAN class="token statement"&gt;&amp;nbsp; where&lt;/SPAN&gt; Randomized_date between "&amp;amp;datebegin"d and "&amp;amp;dateend"d&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token operator"&gt;&lt;SPAN class="token string"&gt;This will filter randomized_date to a range between two &lt;EM&gt;&lt;STRONG&gt;date literals&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;&amp;nbsp; (i.e. like&amp;nbsp; "19dec2016"d&amp;nbsp;&amp;nbsp; and "22dec2016"d).&amp;nbsp;&amp;nbsp; You'll now be comparing&amp;nbsp; randomized_date to&amp;nbsp;numeric values.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 04:06:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321381#M61954</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-12-28T04:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321382#M61955</link>
      <description>&lt;P&gt;Without seeing your CSV file (if you could attach it, that would be great!), it's hard to be precise. But I know immediately what the ERROR condition relates to - you haven't told the&amp;nbsp;&lt;EM&gt;where&lt;/EM&gt; clause that you're comparing&amp;nbsp;&lt;EM&gt;randomized&lt;/EM&gt;&lt;EM&gt;_date&lt;/EM&gt; with two date constants.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change the top of your code to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let datebegin = %sysevalf('19dec2016'd);
%let dateend = %sysevalf('22dec2016'd);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and the&amp;nbsp;&lt;EM&gt;where&lt;/EM&gt; clause to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where Randomized_date between &amp;amp;datebegin and &amp;amp;dateend&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(note - no quotes!)&lt;/P&gt;
&lt;P&gt;and Bob's your auntie.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's how I'm skinning this particular cat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS: Change the data steps to this, just to save unnecessary processing)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.enrollmentbysubject;
	set work.enrollmentbysubject;
	if compress(cats(CDRN), '.')=' ' then
		delete;
	Randomized_date = datepart(input(Randomized, anydtdtm23.));
    format Randomized_date yymmdds10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, may I ask why you've got a&amp;nbsp;&lt;EM&gt;distinct&lt;/EM&gt; keyword in your&amp;nbsp;&lt;EM&gt;select&lt;/EM&gt; clause? I'm always a bit concerned when I see that, because it always has such a tendency to cover up data irregularities (and slows the processing down). It'd be better to remove that and append&amp;nbsp;&lt;EM&gt;cdrn&lt;/EM&gt; to your&amp;nbsp;&lt;EM&gt;group by&lt;/EM&gt; clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is how&amp;nbsp;&lt;EM&gt;I'd&lt;/EM&gt; do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint feedback;
create table work.dailyenrollmenttable_&amp;amp;date. AS
	select cdrn, site,
           (count(Invitation_Code_Used)) AS Golden_Tickets_Entered,
           (count(Randomized)) AS Enrolled,
           calculated golden_tickets_entered / calculated enrolled as percent_enrolled format=percent8.2,
           (count(Randomized_date)) AS Patients_Enrolled_Per_week
      from enrollmentbysubject
     where Randomized_date between &amp;amp;datebegin and &amp;amp;dateend
    Group By cdrn, site;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But because I can't see the data, I can't be sure it'll give you what you want.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 04:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321382#M61955</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2016-12-28T04:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321501#M61962</link>
      <description>&lt;P&gt;Hi Laurie,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much for your reply, I really appreciate it! I tried your suggestions, and unfortunately it didn't work out for me. &amp;nbsp;It keeps returning empty datasets (i.e.: It creates all the columns I want, but there are no values for the different variables). &amp;nbsp;I can't attach the data, as there is sensitive patient info, but I can add example data. &amp;nbsp;It is listed below. &amp;nbsp;I only want to count the randomized column if it has a datetime variable and is between my set macrovariables. &amp;nbsp;Please keep in mind, the data below is raw (with some hidden columns that contained the sensitive info) and before using datepart on the randomized column. &amp;nbsp;I'm also pasting in the log when I ran it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;CDRN&lt;/TD&gt;&lt;TD&gt;Site&lt;/TD&gt;&lt;TD&gt;Randomized&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C1&amp;nbsp;NYC&lt;/TD&gt;&lt;TD&gt;Cornell&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;12/19/2016 17:18&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C1 NYC&lt;/TD&gt;&lt;TD&gt;Columbia&lt;/TD&gt;&lt;TD&gt;12/20/2016 9:37&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C2 Mid Atlantic&lt;/TD&gt;&lt;TD&gt;Vanderbilt University&lt;/TD&gt;&lt;TD&gt;12/20/2016 19:51&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C2 Mid Atlantic&lt;/TD&gt;&lt;TD&gt;Vanderbilt University&lt;/TD&gt;&lt;TD&gt;12/19/2016 16:47&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C3 Florida&lt;/TD&gt;&lt;TD&gt;UF&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN&gt;C&lt;/SPAN&gt;&lt;SPAN&gt;3 Florida&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;UF&lt;/TD&gt;&lt;TD&gt;12/22/2016 18:52&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C4 California&lt;/TD&gt;&lt;TD&gt;UC Irvine&lt;/TD&gt;&lt;TD&gt;12/22/2016 9:48&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C4 California&lt;/TD&gt;&lt;TD&gt;UC Irvine&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;247 /*convert datetimes in column "Randomized" to SAS datetimes*/&lt;BR /&gt;248 data work.enrollmentbysubject;&lt;BR /&gt;249 set work.enrollmentbysubject;&lt;BR /&gt;250 if compress(cats(CDRN), '.')=' ' then&lt;BR /&gt;251 delete;&lt;BR /&gt;252 Randomized_date = datepart(input(Randomized, anydtdtm23.));&lt;BR /&gt;253 format Randomized_date yymmdds10.;&lt;BR /&gt;254 run;&lt;/P&gt;&lt;P&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;BR /&gt;Each place is given by: (Number of times) at (Line):(Column).&lt;BR /&gt;883 at 252:23&lt;BR /&gt;NOTE: There were 1578 observations read from the data set WORK.ENROLLMENTBYSUBJECT.&lt;BR /&gt;NOTE: The data set WORK.ENROLLMENTBYSUBJECT has 1577 observations and 28 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;255 /*create table that I want*/&lt;BR /&gt;256 proc sql noprint feedback;&lt;BR /&gt;257 create table work.dailyenrollmenttable_&amp;amp;date. AS&lt;BR /&gt;258 select cdrn, site,&lt;BR /&gt;259 (count(Invitation_Code_Used)) AS Golden_Tickets_Entered,&lt;BR /&gt;260 (count(Randomized)) AS Enrolled,&lt;BR /&gt;261 calculated golden_tickets_entered / calculated enrolled as percent_enrolled&lt;BR /&gt;261! format=percent8.2,&lt;BR /&gt;262 (count(Randomized_date)) AS Patients_Enrolled_Per_week&lt;BR /&gt;263 from enrollmentbysubject&lt;BR /&gt;264 where Randomized_date between &amp;amp;datebegin and &amp;amp;dateend&lt;BR /&gt;265 Group By cdrn, site;&lt;BR /&gt;NOTE: Statement transforms to:&lt;/P&gt;&lt;P&gt;select ENROLLMENTBYSUBJECT.CDRN, ENROLLMENTBYSUBJECT.Site,&lt;BR /&gt;COUNT(ENROLLMENTBYSUBJECT.Invitation_Code_Used) as Golden_Tickets_Entered,&lt;BR /&gt;COUNT(ENROLLMENTBYSUBJECT.Randomized) as Enrolled, calculated Golden_Tickets_Entered /&lt;BR /&gt;calculated Enrolled as percent_enrolled format=PERCENT8.2,&lt;BR /&gt;COUNT(ENROLLMENTBYSUBJECT.Randomized_date) as Patients_Enrolled_Per_week&lt;BR /&gt;from WORK.ENROLLMENTBYSUBJECT&lt;BR /&gt;where (ENROLLMENTBYSUBJECT.Randomized_date between 20807 and 20810)&lt;BR /&gt;group by ENROLLMENTBYSUBJECT.CDRN, ENROLLMENTBYSUBJECT.Site;&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.DAILYENROLLMENTTABLE_20161218 created, with 0 rows and 6 columns.&lt;/P&gt;&lt;P&gt;266 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that help any?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 00:14:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321501#M61962</guid>
      <dc:creator>pkantak</dc:creator>
      <dc:date>2016-12-29T00:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321502#M61963</link>
      <description>&lt;P&gt;Hi Mkeintz,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks much for your reply! I truly appreciate it. &amp;nbsp;Unfortunately, your suggestions didn't work for me. &amp;nbsp;It was much the same as Laurie's suggestion below (i.e.: returned empty datasets). &amp;nbsp;I responded to her message with some example data. &amp;nbsp;I really hope that can help in answering my question!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 00:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321502#M61963</guid>
      <dc:creator>pkantak</dc:creator>
      <dc:date>2016-12-29T00:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321504#M61964</link>
      <description>&lt;P&gt;You have the note:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;NOTE: Missing values were generated as a result of performing an operation on missing values.&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;Each place is given by: (Number of times) at (Line):Column).&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;883 at 252:23&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;referring to this statement:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; 252 Randomized_date = datepart(input(Randomized, anydtdtm23.));&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So out of 1,578 total records read,&amp;nbsp;this happens 883 times.&amp;nbsp; Is that to be expected?&amp;nbsp; If not, I'd solve that problem first, as it may be the reason your final data set is empty.&amp;nbsp; After all, you have eliminated the data type error, and you now have a logic error - i.e. your filter, which counts and evaluates &lt;EM&gt;&lt;STRONG&gt;randomized_date&lt;/STRONG&gt;&lt;/EM&gt;, is unintentionally removing cases you presumably know to be in the data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 00:30:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321504#M61964</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-12-29T00:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321505#M61965</link>
      <description>&lt;P&gt;Hmm - try this - it works for me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date=20161218;
%let datebegin = %sysevalf('19dec2016'd);
%let dateend = %sysevalf('22dec2016'd);

data enrollmentbysubject;
infile cards dsd dlm=',' missover;
attrib cdrn length=$ 20;
attrib site length=$ 30;
attrib randomized length=8. informat=anydtdtm23. format=datetime23.;
input cdrn
      site
      randomized;
cards;
C1 NYC,Cornell,12/19/2016 17:18
C1 NYC,Columbia,12/20/2016 9:37
C2 Mid Atlantic,Vanderbilt University,12/20/2016 19:51
C2 Mid Atlantic,Vanderbilt University,12/19/2016 16:47
C3 Florida,UF	 
C3 Florida,UF,12/22/2016 18:52
C4 California,UC Irvine,12/22/2016 9:48
C4 California,UC Irvine	 
;
run;

data enrollmentbysubject;
set enrollmentbysubject;
attrib randomized_date length=4 format=yymmdds10.;
if strip(cdrn) notin('.', ' '); 
Randomized_date = datepart(Randomized);
if ranuni(225465114) &amp;lt; .5 then
   invitation_code_used = 'Y';
run;

proc sql noprint feedback;
create table work.dailyenrollmenttable_&amp;amp;date. AS
	select cdrn, site,
           (count(Invitation_Code_Used)) AS Golden_Tickets_Entered,
           (count(Randomized)) AS Enrolled,
           calculated golden_tickets_entered / calculated enrolled as percent_enrolled format=percent8.2,
           (count(Randomized_date)) AS Patients_Enrolled_Per_week
      from enrollmentbysubject
     where Randomized_date between &amp;amp;datebegin and &amp;amp;dateend
    group by cdrn, site;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that I've randomly assigned 'Y' to&amp;nbsp;&lt;EM&gt;invitation_code_used&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Additionally, noting&amp;nbsp;we are two countries divided by a common language, Laurie is a male name…&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2016 00:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/321505#M61965</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2016-12-29T00:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/322434#M62018</link>
      <description>&lt;P&gt;Hi Laurie,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sorry for the late reply, with holiday travel etc I got a bit behind on things. Hope you had a great New Year!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm SO SORRY. &amp;nbsp;Thank you so much for correcting me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on your code, I formulated the code below, which works for me. &amp;nbsp;However, there are some small problems:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* program for creating enrollment table*/
%let date=20170102;
%let datebegin = %sysevalf('26dec2016'd);
%let dateend = %sysevalf('02jan2017'd);
/*import csv*/
 proc import out=work.enrollmentbysubject datafile="Z:\ADAPTABLE\Mytrus\Pickups from Mytrus\&amp;amp;date.\enrollmentbysubject.csv" 
		dbms=csv replace;
	getnames=yes;
	datarow=2;
	guessingrows=20000;
run;

data work.enrollmentbysubject;
	set work.enrollmentbysubject;
	if compress(cats(CDRN), '.')=' ' then
		delete;
run;
/*convert datetimes in column "Randomized" to SAS datetimes*/
data work.enrollmentbysubject;
	set work.enrollmentbysubject;
	Randomized_date = datepart(input(Randomized, anydtdtm23.));
    format Randomized_date yymmdds10.;
run;
/*create table that I want*/
proc sql noprint feedback;
create table work.dailyenrollmenttable_&amp;amp;date. AS
	select distinct cdrn, site,
           count(Invitation_Code_Used) AS Golden_Tickets_Entered,
           count(Randomized) AS Enrolled,
           (calculated enrolled / calculated golden_tickets_entered) as percent_enrolled format=percent8.2
	from work.enrollmentbysubject
	 Group by site;
quit;
proc sql noprint feedback;
create table work.patientsenrolledperweek_&amp;amp;date. AS
select distinct cdrn, site, count(Randomized_date) AS Patients_Enrolled_Per_week
from work.enrollmentbysubject
where Randomized_date between &amp;amp;datebegin and &amp;amp;dateend
group by site;
quit;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) if I move the below statements into my first proc sql statement, then the table that is returned just has the patients enrolled per week. &amp;nbsp;Meaning, for example Penn St has 88 Golden Tickets Entered, 28 enrolled, and 31.82% enrolled. &amp;nbsp;But if I add the Patients_Enrolled_Per Week column it will put that value in all of the columns. &amp;nbsp;Do you know why this is? So the way I got around that was just by making 2 separate tables and than manually inputting the "patients enrolled per week" into the other table. &amp;nbsp;Doesn't seem like the most efficient thing in the world...&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;count(Randomized_date) AS Patients_Enrolled_Per_week&lt;BR /&gt;&lt;BR /&gt;where Randomized_date between &amp;amp;datebegin and &amp;amp;dateend&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Lets say for discussion purposes, that I have 15 sites that I'm gathering enrollment data for (meaning 15 rows in my table). &amp;nbsp;If one site, say Montefiore Medical Center, does not enroll any patients that week, how do I populate the Patients_Enrolled_Per_Week table with a "0". &amp;nbsp;Right now it only is showing me sites that do have a positive count.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) In your code below, I don't really understand the point of your&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;ranuni&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;225465114&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;5&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt;
   invitation_code_used &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'Y'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;in your data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for helping me out with this, you've been a lifesaver!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pete&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2017 16:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/322434#M62018</guid>
      <dc:creator>pkantak</dc:creator>
      <dc:date>2017-01-04T16:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/322820#M62043</link>
      <description>&lt;P&gt;Don't apologise. Nobody expect anybody to do anything over this period. Especially in New Zealand. It's New Year doesn't officially (not really) end until about the 20th - I've had people say "Happy New Year" when I meet them for the first time in February! (Idiots)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm going to cover the two easy ones first:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;coalesce(count(Randomized_date), 0) AS Patients_Enrolled_Per_week&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The&amp;nbsp;&lt;EM&gt;coalesce&lt;/EM&gt; (in this context) doesn't kick in until&amp;nbsp;&lt;EM&gt;after&lt;/EM&gt; the&amp;nbsp;&lt;EM&gt;group by&lt;/EM&gt; has been processed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ranuni(225465114) &amp;lt; .5 then
   invitation_code_used = 'Y';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I didn't have access to your&amp;nbsp;&lt;EM&gt;invitation_code_used&lt;/EM&gt;, so I threw a coin to see if it came down&amp;nbsp;&lt;EM&gt;Y&lt;/EM&gt;. &lt;EM&gt;225465114&amp;nbsp;&lt;/EM&gt;is an old (UK) phone number of mine - I use it as a random seed when I want to reproduce results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for your other problem: if I interpret what you're asking correctly, the first block of code woudl be getting all&amp;nbsp;&lt;EM&gt;Patients_Enrolled_Per_Week&lt;/EM&gt; over all enrollments for all time per site; the second block is only calculating them for that week.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you could do, if you don't need&amp;nbsp;&lt;EM&gt;dailyenrollmenttable_&amp;amp;date&lt;/EM&gt; for anything else, is to create it as a view.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm still a little concerned about the&amp;nbsp;&lt;EM&gt;distinct&lt;/EM&gt; keyword - I don't think it's doing you any favours.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 22:06:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/322820#M62043</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-05T22:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/322991#M62050</link>
      <description>&lt;P&gt;Oh wow that's interesting. &amp;nbsp;I didn't know that! And I definitely didn't get anything done in that time frame.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding the "if ranuni" I understand. For some reason it didn't click in my head that you were creating data for SAS since you didn't have my excel file.......sorry about that!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok so I changed the "distinct" to "group by cdrn, site" and the works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;coalesce(count(Randomized_date), 0) AS Patients_Enrolled_Per_week&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;That didn't change anything in the patientsenrolledperweek_&amp;amp;date. table. &amp;nbsp;If I understand the function of "coalesce" it makes a priority the count of the Randomized_date variable, and then if there is a null value (i.e.: they don't have any patients ) it will choose from the second argument (i.e.: in this case 0). &amp;nbsp;Your logic makes sense to me, but I'm not sure why its still only returning non-zero values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're correct. &amp;nbsp;The dailyenrollmenttable_&amp;amp;date is a table that essentially shows a snapshot of how many patients were randomized by each site up until the day that I pull the data. &amp;nbsp;And then the patients_enrolled_per_week is just a snapshot of that week for all sites.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately the dailyenrollmenttable_&amp;amp;date is actually the main file that I need. &amp;nbsp;I just need the patientsenrolledperweek_&amp;amp;date ammended as the last column. &amp;nbsp;My brute force method would just be to create two tables with the same number of rows and just merge them before I export to an excel file. &amp;nbsp;But that only works if I can get the coalesce to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any thoughts would as always, be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pete&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 14:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/322991#M62050</guid>
      <dc:creator>pkantak</dc:creator>
      <dc:date>2017-01-06T14:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Sql Create Table Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/323106#M62066</link>
      <description>&lt;P&gt;The&amp;nbsp;&lt;EM&gt;coalesce&lt;/EM&gt; probably made no difference because&amp;nbsp;&lt;EM&gt;randomized_date&lt;/EM&gt; has no missing values. If in fact there are, I'm puzzled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think making the&amp;nbsp;&lt;EM&gt;perweek&lt;/EM&gt; dataset a subset of the master is the best way to go - set up all the data correctly in one, then do the fancy work in the subset.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 22:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-Sql-Create-Table-Error/m-p/323106#M62066</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-06T22:06:55Z</dc:date>
    </item>
  </channel>
</rss>

