<?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: newbie having trouble with proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/newbie-having-trouble-with-proc-sql/m-p/608756#M177195</link>
    <description>&lt;P&gt;ProdType is mispelled and actually "PodType" but below is a way of doing this with PROC SQL;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: You have multiple other issues with your input step as well. Either this was due to your copy/paste and/or not inserting the code into the code brackets or due to your original input. You will need to fix that as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data problem3;
input ProdNum ProdName$ 6-27 ManuNum PodType$33-43 RtlCost dollar8.0;
format RtlCost dollar8.0;
put (_all_) (=);
cards;
5009 Dream Machine          500 Workstation $3,200
4506 Business Machine       450 Workstation $3,345
2101 Travel Laptop         400 Laptop     $2,760
2212 Analog Cell Phone      230 Phone     $35
4509 Digital Cell Phone     245 Phone     $175
5003 Office Phone         560 Phone     $145
1110 Spreadsheet Software   134 Software $300
1200 Database Software     113 Software $799
3409 Statistical Software   243 Software $1,899
2102 Wordprocessor Software 245 Software $345
2200 Graphics Software     246 Software $599
;
proc print data=problem3;
run;
proc sql;
insert into problem3
values(3480, 'Desktop Computer', 780, 'Workstation', 1799);
select * 
from problem3;
quit;
proc sql;
CREATE TABLE Want AS
SELECT *
	  ,CASE WHEN PodType IN ('Workstation', 'Laptop', 'Phone') THEN rtlcost*0.8
	  		ELSE rtlcost*1.2
		END AS newrtlcost
  FROM Problem3;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2019 16:24:23 GMT</pubDate>
    <dc:creator>Krueger</dc:creator>
    <dc:date>2019-12-02T16:24:23Z</dc:date>
    <item>
      <title>newbie having trouble with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/newbie-having-trouble-with-proc-sql/m-p/608739#M177184</link>
      <description>&lt;P&gt;Hello experts, I'm having trouble with this exercise. I am supposed to add a new row to my data table, which worked. Then, I need to have a 20% increase on software products, and 20% discount on all other products. My code keeps having errors and I'm not sure how to fix this. Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;DIV&gt;&lt;FONT&gt;data problem3;&lt;BR /&gt;input ProdNum ProdName$ 6-27 ManuNum PodType$33-43 RtlCost dollar8.0;&lt;BR /&gt;format RtlCost dollar8.0;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;put (_all_) (=);&lt;BR /&gt;cards;&lt;BR /&gt;5009 Dream Machine&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 500 Workstation $3,200&lt;BR /&gt;4506 Business Machine&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 450 Workstation $3,345&lt;BR /&gt;2101 Travel Laptop&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 400 Laptop&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $2,760&lt;BR /&gt;2212 Analog Cell Phone&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 230&amp;nbsp;Phone&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $35&lt;BR /&gt;4509 Digital Cell Phone&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 245&amp;nbsp;Phone&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $175&lt;BR /&gt;5003 Office Phone&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 560&amp;nbsp;Phone&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $145&lt;BR /&gt;1110 Spreadsheet Software&amp;nbsp;&amp;nbsp; 134 Software&amp;nbsp;$300&lt;BR /&gt;1200 Database Software&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 113 Software&amp;nbsp;$799&lt;BR /&gt;3409 Statistical Software&amp;nbsp;&amp;nbsp; 243 Software&amp;nbsp;$1,899&lt;BR /&gt;2102 Wordprocessor Software 245 Software&amp;nbsp;$345&lt;BR /&gt;2200 Graphics Software&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 246&amp;nbsp;Software&amp;nbsp;$599&lt;BR /&gt;;&lt;BR /&gt;proc print data=problem3;&lt;BR /&gt;run;&lt;BR /&gt;proc sql;&lt;BR /&gt;insert into problem3&lt;BR /&gt;values(3480, 'Desktop Computer', 780, 'Workstation', 1799);&lt;BR /&gt;select *&amp;nbsp;&lt;BR /&gt;from problem3;&lt;BR /&gt;quit;&lt;BR /&gt;proc sql;&lt;BR /&gt;insert into problem3&lt;BR /&gt;set rtlcost=rtlcost*1.2&lt;BR /&gt;where ProdType&amp;lt;&amp;gt;='Software';&lt;BR /&gt;update problem3&lt;BR /&gt;set rtlcost=rtlcost*0.8&lt;BR /&gt;where ProdType='Workstation' or 'Laptop' or 'Phone';&lt;BR /&gt;select *&lt;BR /&gt;from problem3;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;Here is the log that says what the error is (everything else was fine):&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT&gt;56&amp;nbsp;&amp;nbsp; set rtlcost=rtlcost*1.2&lt;BR /&gt;57&amp;nbsp;&amp;nbsp; where ProdType&amp;lt;&amp;gt;='Software';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -----&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, !!, *, **, +, ',', -, /, SET, ||.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 02 Dec 2019 15:41:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/newbie-having-trouble-with-proc-sql/m-p/608739#M177184</guid>
      <dc:creator>user1942</dc:creator>
      <dc:date>2019-12-02T15:41:48Z</dc:date>
    </item>
    <item>
      <title>Re: newbie having trouble with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/newbie-having-trouble-with-proc-sql/m-p/608754#M177194</link>
      <description>&lt;P&gt;The where satement is used to select rows from a dataset.&lt;/P&gt;
&lt;P&gt;Use CASE statement to define when to do the calculation.&lt;/P&gt;
&lt;P&gt;The code should look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
.....
case (ProdType&amp;lt;&amp;gt;='Software') then set rtlcost*1.2 as rtlcost;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Check for the exact systax.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 16:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/newbie-having-trouble-with-proc-sql/m-p/608754#M177194</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-12-02T16:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: newbie having trouble with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/newbie-having-trouble-with-proc-sql/m-p/608756#M177195</link>
      <description>&lt;P&gt;ProdType is mispelled and actually "PodType" but below is a way of doing this with PROC SQL;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: You have multiple other issues with your input step as well. Either this was due to your copy/paste and/or not inserting the code into the code brackets or due to your original input. You will need to fix that as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data problem3;
input ProdNum ProdName$ 6-27 ManuNum PodType$33-43 RtlCost dollar8.0;
format RtlCost dollar8.0;
put (_all_) (=);
cards;
5009 Dream Machine          500 Workstation $3,200
4506 Business Machine       450 Workstation $3,345
2101 Travel Laptop         400 Laptop     $2,760
2212 Analog Cell Phone      230 Phone     $35
4509 Digital Cell Phone     245 Phone     $175
5003 Office Phone         560 Phone     $145
1110 Spreadsheet Software   134 Software $300
1200 Database Software     113 Software $799
3409 Statistical Software   243 Software $1,899
2102 Wordprocessor Software 245 Software $345
2200 Graphics Software     246 Software $599
;
proc print data=problem3;
run;
proc sql;
insert into problem3
values(3480, 'Desktop Computer', 780, 'Workstation', 1799);
select * 
from problem3;
quit;
proc sql;
CREATE TABLE Want AS
SELECT *
	  ,CASE WHEN PodType IN ('Workstation', 'Laptop', 'Phone') THEN rtlcost*0.8
	  		ELSE rtlcost*1.2
		END AS newrtlcost
  FROM Problem3;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2019 16:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/newbie-having-trouble-with-proc-sql/m-p/608756#M177195</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2019-12-02T16:24:23Z</dc:date>
    </item>
  </channel>
</rss>

