<?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 IMPORT vs. infile? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-IMPORT-vs-infile/m-p/55719#M15545</link>
    <description>Hi:&lt;BR /&gt;
  Once you have already created a SAS data set with PROC IMPORT, you would then only need a SET statement to reference that dataset:&lt;BR /&gt;
[pre]&lt;BR /&gt;
PROC IMPORT OUT= WORK.PatientEval &lt;BR /&gt;
DATATABLE= "Data Code" &lt;BR /&gt;
DBMS=ACCESS REPLACE;&lt;BR /&gt;
DATABASE="N:\ACGME Competencies\360\Fall 2008 Patient Evaluation\Fall 2008 Patient Evaluation Database.mdb"; &lt;BR /&gt;
SCANMEMO=YES;&lt;BR /&gt;
USEDATE=NO;&lt;BR /&gt;
SCANTIME=YES;&lt;BR /&gt;
RUN;&lt;BR /&gt;
              &lt;BR /&gt;
data NewPatientEval; &lt;B&gt;&lt;BR /&gt;
  set work.patienteval; &lt;/B&gt;&lt;BR /&gt;
pYear = Program*10 + Year;&lt;BR /&gt;
          &lt;BR /&gt;
noCount = 0; /* Counts how many "no" answers for AIDET Questions are given*/&lt;BR /&gt;
if AIDET_1 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_2 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_3 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_4 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_5 = 0 then noCount = noCount+1;&lt;BR /&gt;
... more code ...&lt;BR /&gt;
run;&lt;BR /&gt;
                   &lt;BR /&gt;
proc print data=NewPatientEval;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
     &lt;BR /&gt;
In other words, WORK.PATIENTEVAL is the output from what you read with PROC IMPORT and WORK.NEWPATIENTEVAL is the output from the step or program where you create your new variables. &lt;BR /&gt;
   &lt;BR /&gt;
Although you could do this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  data patienteval;&lt;BR /&gt;
     set patienteval;&lt;BR /&gt;
...more code...&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                 &lt;BR /&gt;
I am not a fan of coding this type of DATA step program, where you have the same dataset name for input (SET statement) and output (DATA statement). So, I would recommend, instead that you use this convention:&lt;BR /&gt;
       &lt;BR /&gt;
[pre]&lt;BR /&gt;
  data newpatienteval;&lt;BR /&gt;
     set patienteval;&lt;BR /&gt;
...more code...&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
The PROC IMPORT step is taking the place of the INPUT in the first program. If you want your final dataset to have the name work.patienteval, then simply change the Proc Import step to create WORK.IMP_PT or something. If you did this, then your final code could be:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  data work.patienteval;&lt;BR /&gt;
     set work.imp_pt;&lt;BR /&gt;
...more code...&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                  &lt;BR /&gt;
 The advantage of the approach in the 1st program is that you are reading the data into SAS data set form AND creating your new variables in one pass through the data. &lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
    <pubDate>Mon, 20 Oct 2008 23:19:16 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2008-10-20T23:19:16Z</dc:date>
    <item>
      <title>PROC IMPORT vs. infile?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-IMPORT-vs-infile/m-p/55718#M15544</link>
      <description>I am a SAS novice. I wrote up code using a "fake" data set so that I could be sure the code worked when I had data. However, I used an infile line to read in the fake data, and PROC IMPORT to read in the real data. Almost everything works the same, except 2 variables I create in the data step (marked in bold) &lt;BR /&gt;
&lt;BR /&gt;
Here is the original code, where i read in the data from a .txt file, and the 2 variables are created and work fine. &lt;BR /&gt;
&lt;BR /&gt;
data PatientEval;&lt;BR /&gt;
filename data 'U:\Patient Eval Study\Fake Patient Eval Data Errors.txt';&lt;BR /&gt;
infile data DLM = '09'X DSD;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
input	ID Resident_ID	Program	Year&lt;BR /&gt;
		Question_1	Question_2	Question_3	Question_4	Question_5	Question_6&lt;BR /&gt;
		Question_7	Question_8	Question_9	Question_10	Question_11	AIDET_1&lt;BR /&gt;
		AIDET_2	AIDET_3	AIDET_4	AIDET_5&lt;BR /&gt;
		;&lt;BR /&gt;
	&lt;BR /&gt;
&lt;B&gt;pYear = Program*10 + Year; /*Creates a variable that reads both Program and Year*/&lt;BR /&gt;
&lt;BR /&gt;
noCount = 0; /* Counts how many "no" answers for AIDET Questions are given*/&lt;BR /&gt;
if AIDET_1 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_2 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_3 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_4 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_5 = 0 then noCount = noCount+1;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
label	Resident_ID 		= 'Resident ID'&lt;BR /&gt;
		Program				= 'Program'&lt;BR /&gt;
		Year				= 'Year'&lt;BR /&gt;
		Question_1			= 'Greeting'&lt;BR /&gt;
		Question_2			= 'Listens'&lt;BR /&gt;
		Question_3			= 'Interested'&lt;BR /&gt;
		Question_4			= 'Respectful'&lt;BR /&gt;
		Question_5			= 'Explicit'&lt;BR /&gt;
		Question_6			= 'Educate'&lt;BR /&gt;
		Question_7			= 'Comprehensible'&lt;BR /&gt;
		Question_8			= 'Collaborative'&lt;BR /&gt;
		Question_9			= 'Engaged'&lt;BR /&gt;
		Question_10			= 'Straightforward'&lt;BR /&gt;
		Question_11			= 'Diplomatic'&lt;BR /&gt;
		pYear				= 'Program and Year'&lt;BR /&gt;
		AIDET_1				= 'Acknowledge'&lt;BR /&gt;
		AIDET_2				= 'Introduce'&lt;BR /&gt;
		AIDET_3				= 'Duration'&lt;BR /&gt;
		AIDET_4				= 'Explain'&lt;BR /&gt;
		AIDET_5				= 'Thank'&lt;BR /&gt;
		noCount				= 'Number of Failed AIDET Questions';&lt;BR /&gt;
;	&lt;BR /&gt;
&lt;BR /&gt;
Here is the new code, with the IMPORT procedure. The 2 variables aren't created here. &lt;BR /&gt;
&lt;BR /&gt;
PROC IMPORT OUT= WORK.PatientEval &lt;BR /&gt;
            DATATABLE= "Data Code" &lt;BR /&gt;
            DBMS=ACCESS REPLACE;&lt;BR /&gt;
     DATABASE="N:\ACGME Competencies\360\Fall 2008 Patient Evaluation\Fall 2008 Patient Evaluation Database.mdb"; &lt;BR /&gt;
     SCANMEMO=YES;&lt;BR /&gt;
     USEDATE=NO;&lt;BR /&gt;
     SCANTIME=YES;&lt;BR /&gt;
RUN;&lt;BR /&gt;
	&lt;BR /&gt;
data PatientEval&lt;BR /&gt;
&lt;BR /&gt;
input	ID Resident_ID	Program	Year&lt;BR /&gt;
		Question_1	Question_2	Question_3	Question_4	Question_5	Question_6&lt;BR /&gt;
		Question_7	Question_8	Question_9	Question_10	Question_11	AIDET_1&lt;BR /&gt;
		AIDET_2	AIDET_3	AIDET_4	AIDET_5&lt;BR /&gt;
		;&lt;BR /&gt;
	&lt;BR /&gt;
&lt;B&gt;pYear = Program*10 + Year; /*Creates a variable that reads both Program and Year*/&lt;BR /&gt;
&lt;BR /&gt;
noCount = 0; /* Counts how many "no" answers for AIDET Questions are given*/&lt;BR /&gt;
if AIDET_1 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_2 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_3 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_4 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_5 = 0 then noCount = noCount+1;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
label	Resident_ID 		= 'Resident ID'&lt;BR /&gt;
		Program				= 'Program'&lt;BR /&gt;
		Year				= 'Year'&lt;BR /&gt;
		Question_1			= 'Greeting'&lt;BR /&gt;
		Question_2			= 'Listens'&lt;BR /&gt;
		Question_3			= 'Interested'&lt;BR /&gt;
		Question_4			= 'Respectful'&lt;BR /&gt;
		Question_5			= 'Explicit'&lt;BR /&gt;
		Question_6			= 'Educate'&lt;BR /&gt;
		Question_7			= 'Comprehensible'&lt;BR /&gt;
		Question_8			= 'Collaborative'&lt;BR /&gt;
		Question_9			= 'Engaged'&lt;BR /&gt;
		Question_10			= 'Straightforward'&lt;BR /&gt;
		Question_11			= 'Diplomatic'&lt;BR /&gt;
		pYear				= 'Program and Year'&lt;BR /&gt;
		AIDET_1				= 'Acknowledge'&lt;BR /&gt;
		AIDET_2				= 'Introduce'&lt;BR /&gt;
		AIDET_3				= 'Duration'&lt;BR /&gt;
		AIDET_4				= 'Explain'&lt;BR /&gt;
		AIDET_5				= 'Thank'&lt;BR /&gt;
		noCount				= 'Number of Failed AIDET Questions';&lt;BR /&gt;
;	&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The log error is:&lt;BR /&gt;
&lt;BR /&gt;
ERROR: NO DATALINES OR INFILE STATEMENT.&lt;BR /&gt;
&lt;BR /&gt;
How do I get the variables to work in the 2nd instance?&lt;BR /&gt;
&lt;BR /&gt;
Thanks, &lt;BR /&gt;
Ashley Adams&lt;BR /&gt;
SEAHEC</description>
      <pubDate>Mon, 20 Oct 2008 21:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-IMPORT-vs-infile/m-p/55718#M15544</guid>
      <dc:creator>AAdams</dc:creator>
      <dc:date>2008-10-20T21:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: PROC IMPORT vs. infile?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-IMPORT-vs-infile/m-p/55719#M15545</link>
      <description>Hi:&lt;BR /&gt;
  Once you have already created a SAS data set with PROC IMPORT, you would then only need a SET statement to reference that dataset:&lt;BR /&gt;
[pre]&lt;BR /&gt;
PROC IMPORT OUT= WORK.PatientEval &lt;BR /&gt;
DATATABLE= "Data Code" &lt;BR /&gt;
DBMS=ACCESS REPLACE;&lt;BR /&gt;
DATABASE="N:\ACGME Competencies\360\Fall 2008 Patient Evaluation\Fall 2008 Patient Evaluation Database.mdb"; &lt;BR /&gt;
SCANMEMO=YES;&lt;BR /&gt;
USEDATE=NO;&lt;BR /&gt;
SCANTIME=YES;&lt;BR /&gt;
RUN;&lt;BR /&gt;
              &lt;BR /&gt;
data NewPatientEval; &lt;B&gt;&lt;BR /&gt;
  set work.patienteval; &lt;/B&gt;&lt;BR /&gt;
pYear = Program*10 + Year;&lt;BR /&gt;
          &lt;BR /&gt;
noCount = 0; /* Counts how many "no" answers for AIDET Questions are given*/&lt;BR /&gt;
if AIDET_1 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_2 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_3 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_4 = 0 then noCount = noCount+1;&lt;BR /&gt;
if AIDET_5 = 0 then noCount = noCount+1;&lt;BR /&gt;
... more code ...&lt;BR /&gt;
run;&lt;BR /&gt;
                   &lt;BR /&gt;
proc print data=NewPatientEval;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
     &lt;BR /&gt;
In other words, WORK.PATIENTEVAL is the output from what you read with PROC IMPORT and WORK.NEWPATIENTEVAL is the output from the step or program where you create your new variables. &lt;BR /&gt;
   &lt;BR /&gt;
Although you could do this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  data patienteval;&lt;BR /&gt;
     set patienteval;&lt;BR /&gt;
...more code...&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                 &lt;BR /&gt;
I am not a fan of coding this type of DATA step program, where you have the same dataset name for input (SET statement) and output (DATA statement). So, I would recommend, instead that you use this convention:&lt;BR /&gt;
       &lt;BR /&gt;
[pre]&lt;BR /&gt;
  data newpatienteval;&lt;BR /&gt;
     set patienteval;&lt;BR /&gt;
...more code...&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
The PROC IMPORT step is taking the place of the INPUT in the first program. If you want your final dataset to have the name work.patienteval, then simply change the Proc Import step to create WORK.IMP_PT or something. If you did this, then your final code could be:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  data work.patienteval;&lt;BR /&gt;
     set work.imp_pt;&lt;BR /&gt;
...more code...&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                  &lt;BR /&gt;
 The advantage of the approach in the 1st program is that you are reading the data into SAS data set form AND creating your new variables in one pass through the data. &lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 20 Oct 2008 23:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-IMPORT-vs-infile/m-p/55719#M15545</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-10-20T23:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: PROC IMPORT vs. infile?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-IMPORT-vs-infile/m-p/55720#M15546</link>
      <description>Thank you!&lt;BR /&gt;
&lt;BR /&gt;
That's all I needed. I appreciate the help!</description>
      <pubDate>Tue, 21 Oct 2008 20:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-IMPORT-vs-infile/m-p/55720#M15546</guid>
      <dc:creator>AAdams</dc:creator>
      <dc:date>2008-10-21T20:57:00Z</dc:date>
    </item>
  </channel>
</rss>

