<?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 In SAS, how to restructure data from Excel in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102354#M258235</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have data that I copied and pasted from a website into an Excel spreadsheet in the attached file. Every 3 rows are actually 1 observation. For eg, the first row is: Brandname of the camera (Canon Powershot G12), the second row is the current price of that camera ($469.99) and the third row is the discount amount on that camera price ($30.00). Then there is blank row and then the next camera, and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to read this data into SAS and create the 3 variables: Brandnamemodel, Price, discountamount. How could this be done?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could not find any help with this online. Thank you so much and look forward to hearing from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kelly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Dec 2012 22:28:05 GMT</pubDate>
    <dc:creator>kellykishan</dc:creator>
    <dc:date>2012-12-17T22:28:05Z</dc:date>
    <item>
      <title>In SAS, how to restructure data from Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102354#M258235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have data that I copied and pasted from a website into an Excel spreadsheet in the attached file. Every 3 rows are actually 1 observation. For eg, the first row is: Brandname of the camera (Canon Powershot G12), the second row is the current price of that camera ($469.99) and the third row is the discount amount on that camera price ($30.00). Then there is blank row and then the next camera, and so on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to read this data into SAS and create the 3 variables: Brandnamemodel, Price, discountamount. How could this be done?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could not find any help with this online. Thank you so much and look forward to hearing from you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kelly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 22:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102354#M258235</guid>
      <dc:creator>kellykishan</dc:creator>
      <dc:date>2012-12-17T22:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS, how to restructure data from Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102355#M258236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is one way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT= WORK.have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATAFILE= "C:\art\sampledatanov21.xls" &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=EXCEL REPLACE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=no;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MIXED=NO;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=f:);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain Brandnamemodel Price;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format Price Discount dollar8.2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; f2=find(f1,"$");&lt;/P&gt;&lt;P&gt;&amp;nbsp; select (mod(_n_,4));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (1) Brandnamemodel=strip(f1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (2) Price=input(substr(f1,f2+1),comma32.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; when (3) do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Discount=input(substr(f1,f2+1),comma32.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; otherwise;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 22:58:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102355#M258236</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-12-17T22:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS, how to restructure data from Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102356#M258237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The first thing I would do is make sure the data pattern is actually the same. You have a different record format for&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN lang="EN"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Canon A810 Red + 500 prints Web&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you fix that then 1) save as a CSV file as import from Excel is going to take somewhat more complicated code and&lt;/P&gt;&lt;P&gt;then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;infile 'your path to saved file\sampledatanov21(1).csv' lrecl=256 pad missover ;&lt;/P&gt;&lt;P&gt;informat brandname $50. price discount dollar8.2 junk1 junk2 $4.;&lt;/P&gt;&lt;P&gt;input brandname $ 1-50;&lt;/P&gt;&lt;P&gt;input junk1 $ 1-4 price;&lt;/P&gt;&lt;P&gt;input junk2 $ 1-4 discount;&lt;/P&gt;&lt;P&gt;input;&lt;/P&gt;&lt;P&gt;drop junk:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Worked for me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 23:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102356#M258237</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-12-17T23:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS, how to restructure data from Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102357#M258238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="260198" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: I like your approach. To avoid missing the last record (as if saving it as is, the last empty line will be eliminated), and no need for junk: variables:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;infile 'c:\temp\sampledatanov21.csv' truncover end=last;&lt;/P&gt;&lt;P&gt;informat brandname $50. price discount dollar8.2;&lt;/P&gt;&lt;P&gt;input brandname $&amp;amp;;&lt;/P&gt;&lt;P&gt;input @5 price;&lt;/P&gt;&lt;P&gt;input&amp;nbsp; @5 discount;&lt;/P&gt;&lt;P&gt;if not last then input;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2012 03:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102357#M258238</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-12-18T03:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS, how to restructure data from Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102358#M258239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The column pointers are better when I know what's going on. I wasn't sure if we might get something else in case the data does't follow the pattern in the first few lines of data. That's a habit I got into because I had way too many file layout descriptions not quite match the actual data received. The I don't drop the junk variables for diagnostics.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2012 15:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102358#M258239</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-12-18T15:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS, how to restructure data from Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102359#M258240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hai.kuo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the modified code. It worked perfectly and it was simple as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I am new to SAS could you please explain what $&amp;amp; means? I could not find it anywhere online.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;Kelly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2012 21:12:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102359#M258240</guid>
      <dc:creator>kellykishan</dc:creator>
      <dc:date>2012-12-18T21:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: In SAS, how to restructure data from Excel</title>
      <link>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102360#M258241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Edward, thank you also for your help and input. Greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kelly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2012 21:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/In-SAS-how-to-restructure-data-from-Excel/m-p/102360#M258241</guid>
      <dc:creator>kellykishan</dc:creator>
      <dc:date>2012-12-18T21:14:31Z</dc:date>
    </item>
  </channel>
</rss>

