<?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: Error code in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554828#M9574</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WORK.IMPORT;
INFILE '/folders/myfolders/MIS445/MIS445_FRED-real_GDP.xlsx';
/* you cannot read an Excel file with a data step. Data steps can read text files */
observations = input(FRED_Graph_Observations, 10.); RUN;
/* the previous RUN ends the data step, causing the next statement to be in "open code", where it is not valid */
b_int = input(B, 10.); RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you already have created WORK.IMPORT with the previous proc import (if that worked), but need to convert variables of type character into new ones of type numeric, you can change your data step to this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.import;
set work.import;
observations = input(FRED_Graph_Observations, 10.);
b_int = input(B, 10.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 29 Apr 2019 19:41:06 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-04-29T19:41:06Z</dc:date>
    <item>
      <title>Error code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554824#M9570</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Would someone be able to help me fix this error code?&lt;/P&gt;&lt;DIV&gt;FILENAME REFFILE '/folders/myfolders/MIS445/MIS445_FRED-real_GDP.xlsx';&lt;BR /&gt;&lt;BR /&gt;PROC IMPORT DATAFILE=REFFILE&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=XLSX&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OUT=WORK.IMPORT;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=YES;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;PROC CONTENTS DATA=WORK.IMPORT; RUN;&lt;BR /&gt;&lt;BR /&gt;DATA WORK.IMPORT;&lt;BR /&gt;INFILE '/folders/myfolders/MIS445/MIS445_FRED-real_GDP.xlsx';&lt;BR /&gt;observations = input(FRED_Graph_Observations, 10.); RUN;&lt;BR /&gt;b_int = input(B, 10.); RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%web_open_table(WORK.IMPORT);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This returns&lt;PRE class="m_-6693300904823744593gmail-sasLog"&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 19:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554824#M9570</guid>
      <dc:creator>profjustin</dc:creator>
      <dc:date>2019-04-29T19:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Error code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554825#M9571</link>
      <description>&lt;P&gt;You will need to learn what goes into a DATA step.&amp;nbsp; For now, there are two points to consider:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You have an extra RUN statement.&amp;nbsp; You need one at the end of the DATA step, but you have an extra one in the middle.&lt;/LI&gt;
&lt;LI&gt;Importing the data creates a SAS data set named IMPORT.&amp;nbsp; If you want to use it, you don't need an INFILE statement.&amp;nbsp; Instead, use:&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;data import2;&lt;/P&gt;
&lt;P&gt;set import;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;observations = input(FRED_Graph_Observations, 10.);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;b_int = input(B, 10.); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;RUN;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Once you have a SAS data set, you don't need to refer to the spreadsheet that was used to create it.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 19:37:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554825#M9571</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-29T19:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554826#M9572</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 19:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554826#M9572</guid>
      <dc:creator>profjustin</dc:creator>
      <dc:date>2019-04-29T19:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554827#M9573</link>
      <description>&lt;P&gt;You should comment your steps, it helps to find logical issues in your process:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your issue is with the data step. Since you've already read in the file you don't need to read it in again and you can't read Excel files with INFILE.I would really recommend using more descriptive data set names as well. You also have a RUN statement too early, it ends the data step when you still want to do calculations.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Import2;

set Import;

observations = input(FRED_Graph_Observations, 10.); 

b_int = input(B, 10.);

 RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Ideally your program would look like the following, note the comments and I changed the items in red. Hopefully this works for you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;*path to file to import into SAS;
FILENAME REFFILE '/folders/myfolders/MIS445/MIS445_FRED-real_GDP.xlsx';

*Import Excel File;
PROC IMPORT DATAFILE=REFFILE
    DBMS=XLSX
    OUT=&lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;Fred_GDP&lt;/STRONG&gt;&lt;/FONT&gt;;
    GETNAMES=YES;
RUN;

PROC CONTENTS DATA=FRED_GDP; RUN;

*convert variables to numbers;
data &lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;fred2;&lt;/STRONG&gt;&lt;/FONT&gt;
set &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;fred_gdp;&lt;/STRONG&gt;&lt;/FONT&gt;

observations = input(FRED_Graph_Observations, 10.);&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; *remove early RUN;&lt;/STRONG&gt;&lt;/FONT&gt;
b_int = input(B, 10.); 

 RUN;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/272279"&gt;@profjustin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Would someone be able to help me fix this error code?&lt;/P&gt;
&lt;DIV&gt;FILENAME REFFILE '/folders/myfolders/MIS445/MIS445_FRED-real_GDP.xlsx';&lt;BR /&gt;&lt;BR /&gt;PROC IMPORT DATAFILE=REFFILE&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=XLSX&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; OUT=WORK.IMPORT;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=YES;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;PROC CONTENTS DATA=WORK.IMPORT; RUN;&lt;BR /&gt;&lt;BR /&gt;DATA WORK.IMPORT;&lt;BR /&gt;INFILE '/folders/myfolders/MIS445/MIS445_FRED-real_GDP.xlsx';&lt;BR /&gt;observations = input(FRED_Graph_Observations, 10.); RUN;&lt;BR /&gt;b_int = input(B, 10.); RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%web_open_table(WORK.IMPORT);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;This returns
&lt;PRE class="m_-6693300904823744593gmail-sasLog"&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 19:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554827#M9573</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-04-29T19:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554828#M9574</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA WORK.IMPORT;
INFILE '/folders/myfolders/MIS445/MIS445_FRED-real_GDP.xlsx';
/* you cannot read an Excel file with a data step. Data steps can read text files */
observations = input(FRED_Graph_Observations, 10.); RUN;
/* the previous RUN ends the data step, causing the next statement to be in "open code", where it is not valid */
b_int = input(B, 10.); RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you already have created WORK.IMPORT with the previous proc import (if that worked), but need to convert variables of type character into new ones of type numeric, you can change your data step to this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.import;
set work.import;
observations = input(FRED_Graph_Observations, 10.);
b_int = input(B, 10.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Apr 2019 19:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554828#M9574</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-29T19:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Error code</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554830#M9575</link>
      <description>&lt;P&gt;INFILE tells SAS that you are going to write input specifications to read a text file. XLSX are not text files. A single RUN statement will end a data step.&lt;/P&gt;
&lt;P&gt;You should show the entire log of the code submitted plus the error message. Copy from the log and paste into a code box opened with the forum's {I} or "running man" icon. The particular error you show should have at least one line of code with underscores indicating the invalid syntax. If you paste the entire code step with the error in a code box the format of the message will be maintained and we can provide more help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Likely you wanted to manipulate something in the WORK.IMPORT data set. You reference that in a SET statement. Do not go back and attempt to reread the xlsx.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this maybe. Note that while the syntax allows the same input and output set names doing so often leads to hard to diagnose data issues as the code would completely replace the original data set. If the logic is incorrect then you need to go back to get the original input set.&lt;/P&gt;
&lt;PRE&gt;data work.import2;
   set work.import;
   observations = input(FRED_Graph_Observations, 10.);
   b_int = input(B, 10.); 
RUN;&lt;/PRE&gt;
&lt;P&gt;RUN will end a data step block of code. So everything after your first RUN; was syntactically wrong as well. The input calls are only needed if&amp;nbsp;the variable is character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2019 22:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Error-code/m-p/554830#M9575</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-29T22:48:28Z</dc:date>
    </item>
  </channel>
</rss>

