<?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 Convert PROC SQL to SAS Base code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-PROC-SQL-to-SAS-Base-code/m-p/544458#M150575</link>
    <description>&lt;P&gt;Hi how may I change the following PROC SQL code to SAS code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried everything I know but it gives me errors such as " Mathematical operations could not be performed at the following places. The results of the operations have been set to missing values."&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;RescaledValues is a csv dataset in my local file with no missing values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scores is a SAS dataset with no missing values.&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 sql;
    create table RescaledValues as
    select PageID , 100*(pageLikesN-min(pageLikesN))/(max(pageLikesN)-min(pageLikesN)) as pageLikes,
			100*(commentsCountN-min(commentsCountN))/(max(commentsCountN)-min(commentsCountN)) as commentsCount,
			100*(likesCountN-min(likesCountN))/(max(likesCountN)-min(likesCountN)) as likesCount,
			100*(sharesCountN-min(sharesCountN))/(max(sharesCountN)-min(sharesCountN)) as sharesCount,
			100*(pscoreMN-min(pscoreMN))/(max(pscoreMN)-min(pscoreMN)) as pscoreM,
			100*(nscoreMN-min(nscoreMN))/(max(nscoreMN)-min(nscoreMN)) as nscoreM
			from Scores;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Mar 2019 07:20:06 GMT</pubDate>
    <dc:creator>weng1</dc:creator>
    <dc:date>2019-03-20T07:20:06Z</dc:date>
    <item>
      <title>Convert PROC SQL to SAS Base code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-PROC-SQL-to-SAS-Base-code/m-p/544458#M150575</link>
      <description>&lt;P&gt;Hi how may I change the following PROC SQL code to SAS code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried everything I know but it gives me errors such as " Mathematical operations could not be performed at the following places. The results of the operations have been set to missing values."&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;RescaledValues is a csv dataset in my local file with no missing values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Scores is a SAS dataset with no missing values.&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 sql;
    create table RescaledValues as
    select PageID , 100*(pageLikesN-min(pageLikesN))/(max(pageLikesN)-min(pageLikesN)) as pageLikes,
			100*(commentsCountN-min(commentsCountN))/(max(commentsCountN)-min(commentsCountN)) as commentsCount,
			100*(likesCountN-min(likesCountN))/(max(likesCountN)-min(likesCountN)) as likesCount,
			100*(sharesCountN-min(sharesCountN))/(max(sharesCountN)-min(sharesCountN)) as sharesCount,
			100*(pscoreMN-min(pscoreMN))/(max(pscoreMN)-min(pscoreMN)) as pscoreM,
			100*(nscoreMN-min(nscoreMN))/(max(nscoreMN)-min(nscoreMN)) as nscoreM
			from Scores;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 07:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-PROC-SQL-to-SAS-Base-code/m-p/544458#M150575</guid>
      <dc:creator>weng1</dc:creator>
      <dc:date>2019-03-20T07:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Convert PROC SQL to SAS Base code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-PROC-SQL-to-SAS-Base-code/m-p/544462#M150579</link>
      <description>&lt;P&gt;Hi and welcome to the SAS Communities &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you show us the code you have tried and that generates the error? Also, see if this works for you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data RescaledValues;
   set Scores;
   keep PageID pageLikes commentsCount likesCount sharesCount pscoreM nscoreM;
   pageLikes=100*(pageLikesN-min(pageLikesN))/(max(pageLikesN)-min(pageLikesN));
   commentsCount=100*(commentsCountN-min(commentsCountN))/(max(commentsCountN)-min(commentsCountN));
   likesCount=100*(likesCountN-min(likesCountN))/(max(likesCountN)-min(likesCountN));
   sharesCount=100*(sharesCountN-min(sharesCountN))/(max(sharesCountN)-min(sharesCountN));
   pscoreM=100*(pscoreMN-min(pscoreMN))/(max(pscoreMN)-min(pscoreMN));
   nscoreM=100*(nscoreMN-min(nscoreMN))/(max(nscoreMN)-min(nscoreMN));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Mar 2019 07:26:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-PROC-SQL-to-SAS-Base-code/m-p/544462#M150579</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-03-20T07:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Convert PROC SQL to SAS Base code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-PROC-SQL-to-SAS-Base-code/m-p/544467#M150582</link>
      <description>&lt;P&gt;Please post the log, using the {i} button.&lt;/P&gt;
&lt;P&gt;And give us a short sample of your data like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data scores;
input pageid $ pagelikesn;
cards;
1 20
2 30
3 0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Mar 2019 07:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-PROC-SQL-to-SAS-Base-code/m-p/544467#M150582</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-20T07:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Convert PROC SQL to SAS Base code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-PROC-SQL-to-SAS-Base-code/m-p/544612#M150622</link>
      <description>&lt;P&gt;You have six bits similar to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;(max(pageLikesN)-min(pageLikesN)) &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;that are used for denominators in division. If any of them result in 0 the division cannot be performed&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also wonder if perhaps you missed an intended GROUP BY PageId. Your existing code would create&amp;nbsp;multiple rows of identical values of the calculated variables for each row of the input data set keeping the Pageid value.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   title 'No group';
   select sex, min(weight)
   from sashelp.class
   ;
   title 'with group';
   select sex, min(weight)
   from sashelp.class
   group by sex
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;Proc SQL will not create a CSV file directly. Either export the created table, use a data step to put to a csv file or possibly use ODS CSV destination and skip the create table and just use the select to send text to the output destination.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2019 15:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-PROC-SQL-to-SAS-Base-code/m-p/544612#M150622</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-20T15:40:43Z</dc:date>
    </item>
  </channel>
</rss>

