<?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 trying to create variable with imported data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/trying-to-create-variable-with-imported-data/m-p/246791#M46234</link>
    <description>&lt;P&gt;I am trying to create a variable for price per carat. I keep recieving an error message saying the command is wrong or not in the proper place.&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code I am trying to use is as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ILENAME CSV "/folders/myfolders/homeworkdata/diamond.csv" TERMSTR=CRLF;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/** Import the CSV file. **/&lt;/P&gt;&lt;P&gt;PROC IMPORT DATAFILE=CSV&lt;BR /&gt;OUT=problem4a&lt;BR /&gt;DBMS=CSV&lt;BR /&gt;REPLACE;&lt;BR /&gt;guessingrows = 1000;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;pricepercarat = (price/carat);&lt;BR /&gt;/** Print the results. **/&lt;/P&gt;&lt;P&gt;PROC PRINT DATA=problem4a; RUN;&lt;/P&gt;&lt;P&gt;/** Unassign the file reference. **/&lt;/P&gt;&lt;P&gt;FILENAME CSV;&lt;/P&gt;&lt;P&gt;proc print data=problem4a (firstobs=131 obs=179);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jan 2016 00:54:30 GMT</pubDate>
    <dc:creator>MadQuidd</dc:creator>
    <dc:date>2016-01-29T00:54:30Z</dc:date>
    <item>
      <title>trying to create variable with imported data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-create-variable-with-imported-data/m-p/246791#M46234</link>
      <description>&lt;P&gt;I am trying to create a variable for price per carat. I keep recieving an error message saying the command is wrong or not in the proper place.&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code I am trying to use is as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ILENAME CSV "/folders/myfolders/homeworkdata/diamond.csv" TERMSTR=CRLF;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/** Import the CSV file. **/&lt;/P&gt;&lt;P&gt;PROC IMPORT DATAFILE=CSV&lt;BR /&gt;OUT=problem4a&lt;BR /&gt;DBMS=CSV&lt;BR /&gt;REPLACE;&lt;BR /&gt;guessingrows = 1000;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;pricepercarat = (price/carat);&lt;BR /&gt;/** Print the results. **/&lt;/P&gt;&lt;P&gt;PROC PRINT DATA=problem4a; RUN;&lt;/P&gt;&lt;P&gt;/** Unassign the file reference. **/&lt;/P&gt;&lt;P&gt;FILENAME CSV;&lt;/P&gt;&lt;P&gt;proc print data=problem4a (firstobs=131 obs=179);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 00:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-create-variable-with-imported-data/m-p/246791#M46234</guid>
      <dc:creator>MadQuidd</dc:creator>
      <dc:date>2016-01-29T00:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: trying to create variable with imported data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-create-variable-with-imported-data/m-p/246794#M46236</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME CSV "/folders/myfolders/homeworkdata/diamond.csv" TERMSTR=CRLF;

/** Import the CSV file. **/
PROC IMPORT DATAFILE=CSV
OUT=problem4a
DBMS=CSV
REPLACE;
guessingrows = 1000;
RUN;

data problem4a;
  set problem4a;
  pricepercarat = (price/carat);
run;

/** Print the results. **/
PROC PRINT DATA=problem4a; RUN;
/** Unassign the file reference. **/
FILENAME CSV;
proc print data=problem4a (firstobs=131 obs=179);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jan 2016 01:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-create-variable-with-imported-data/m-p/246794#M46236</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-01-29T01:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: trying to create variable with imported data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/trying-to-create-variable-with-imported-data/m-p/246795#M46237</link>
      <description>&lt;P&gt;You are getting the error&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;because you create a variable out of the data step _after the run statment_.... and you can not do that.&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;PROC IMPORT DATAFILE=CSV
OUT=problem4a
DBMS=CSV
REPLACE;
guessingrows = 1000;
RUN;
&lt;STRONG&gt;pricepercarat = (price/carat);&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;PROC IMPORT&lt;/STRONG&gt; reads data from an external data source and writes it to a SAS data set. &lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000332606.htm" target="_self"&gt;Overview: IMPORT Procedure&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In sas Coding you have data step and Procedures and inside these you add your code, which end by RUN or QUIT statment. When you run your statment&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;RUN;
pricepercarat = (price/carat);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;in no where like you did.&amp;nbsp;Where do you think it will run? And for which data.&amp;nbsp;Be carefull ....&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jan 2016 01:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/trying-to-create-variable-with-imported-data/m-p/246795#M46237</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-29T01:07:19Z</dc:date>
    </item>
  </channel>
</rss>

