<?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: New User, Code works if run in seperate parts, not if run as  a whole, code/error messages inclu in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658272#M197286</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/331831"&gt;@School_UD&lt;/a&gt;&amp;nbsp; For N literals to work, wouldn't you be needing&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;OPTIONS VALIDVARNAME=ANY; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;? I vaguely remember that setting is needed? Please do correct me if i am wrong&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 13 Jun 2020 14:21:32 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-06-13T14:21:32Z</dc:date>
    <item>
      <title>New User, Code works if run in seperate parts, not if run as  a whole, code/error messages included</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658271#M197285</link>
      <description>&lt;P&gt;Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a new to both SAS and the forums. If I have posted this in the wrong place, let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below works if I run it in parts, i.e. if I run everything separated by comments separately. Yet when I try to run the program as a whole, without singling out certain code, I receive a large number of errors. (Examples included below). These errors do not occur, and the tables I am looking for are created, if I run separately. All of the errors are centered around the custom column names I have pulled, or created. I am using SAS Studio.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for the advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;T&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname data "/home/&amp;amp;sysuserid/DND_Data/";
libname xlclass xlsx "/home/&amp;amp;sysuserid/DND_Data/Crafting Log.xlsx";
OPTIONS VALIDVARNAME=V7; 

/* Edit these StartDate and EndDate to match desired month. If all time desired use 01JAN2020 - 31DEC2030 */
%let StartDate=01may2020;
%let EndDate=31may2020;
/*Creates Three Tables:
	1. Final Item Cost Summary: Computes total cost for each item created in the given date range and sums them for a monthly Total
	2. Monthly Alchemical Creation Summary: Computes Total Unit Cost for each item then sums for a total Alchemical Creation Cost
	3. Monthly Potion Brewing Summary: Computes Brewing Cost for the dates specified.*/
data Final_Sum;
	set xlclass.'Brewing Potions'n xlclass.'Alchemical Creations'n;
	where ("&amp;amp;StartDate"d &amp;lt;= Date &amp;lt;= "&amp;amp;EndDate"d);
	'Total Reagent Cost'n = sum("Reagent Cost GP"n, 'Failure Costs GP'n);
	'Final Cost'n = Sum("Brewing Cost"n, 'Total Reagent Cost'n);
	Keep Item 'Brewing Cost'n 'Total Reagent Cost'n 'Final Cost'n;
	format 'Total Reagent Cost'n comma7.;
	format 'Brewing Cost'n comma7.;
	format 'Final Cost'n comma7.;
run;

proc sort data=Final_Sum out=Final_SumF (keep= Item 'Final Cost'n);
	by descending 'Final Cost'n;
run;

Title1 "Final Item Cost Summary";
proc print data=Final_SumF;
	var Item 'Final Cost'n;
	SUM 'Final Cost'n;			
run;

data monthly_sumA;
	set xlclass.'Alchemical Creations'n;
	where ("&amp;amp;StartDate"d &amp;lt;= Date &amp;lt;= "&amp;amp;EndDate"d);
	'Total Unit Cost'n = sum("Reagent Cost GP"n, 'Failure Costs GP'n);
	keep Item 'Reagent Cost GP'n 'Failure Costs GP'n 'Total Unit Cost'n;
	format 'Total Unit Cost'n comma7.;
run;

proc sort data=monthly_sumA out=Monthly_CostsA (keep= Item 'Reagent Cost GP'n 'Failure Costs GP'n 'Total Unit Cost'n);
	by descending 'Total Unit Cost'n descending 'Reagent Cost GP'n descending 'Failure Costs GP'n;
run;

TITLE1 "Monthly Alchemical Creation Summary";
proc print data=Monthly_CostsA;
	SUM 'Reagent Cost GP'n 'Failure Costs GP'n 'Total Unit Cost'n;			
run;

data monthly_sumB;
	set xlclass.'Brewing Potions'n;
	where ("&amp;amp;StartDate"d &amp;lt;= Date &amp;lt;= "&amp;amp;EndDate"d);
	keep Item 'Brewing Cost'n;
	format 'Brewing Cost'n comma7.;
run;

proc sort data=monthly_sumB out=Monthly_CostsB (keep= Item 'Brewing Cost'n);
	by descending 'Brewing Cost'n;
run;

TITLE1 "Monthly Potion Brewing Summary";
proc print data=Monthly_CostsB;
	SUM 'Brewing Cost'n;			
run;
title;	
libname xlclass clear;
libname data clear;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 929px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/42910i7D5BDEE17C5FB59B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 14:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658271#M197285</guid>
      <dc:creator>School_UD</dc:creator>
      <dc:date>2020-06-13T14:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: New User, Code works if run in seperate parts, not if run as  a whole, code/error messages inclu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658272#M197286</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/331831"&gt;@School_UD&lt;/a&gt;&amp;nbsp; For N literals to work, wouldn't you be needing&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;OPTIONS VALIDVARNAME=ANY; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;? I vaguely remember that setting is needed? Please do correct me if i am wrong&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 14:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658272#M197286</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-13T14:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: New User, Code works if run in seperate parts, not if run as  a whole, code/error messages inclu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658273#M197287</link>
      <description>&lt;P&gt;To use the dumb names (instead of valid SAS names that don't need ' 'n around them), you need&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Jun 2020 14:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658273#M197287</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-13T14:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: New User, Code works if run in seperate parts, not if run as  a whole, code/error messages inclu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658275#M197289</link>
      <description>That did the trick. Thank you for the quick response.</description>
      <pubDate>Sat, 13 Jun 2020 14:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658275#M197289</guid>
      <dc:creator>School_UD</dc:creator>
      <dc:date>2020-06-13T14:30:10Z</dc:date>
    </item>
    <item>
      <title>Re: New User, Code works if run in seperate parts, not if run as  a whole, code/error messages inclu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658276#M197290</link>
      <description>Thank you. That did the trick. Thanks for the quick response.</description>
      <pubDate>Sat, 13 Jun 2020 14:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658276#M197290</guid>
      <dc:creator>School_UD</dc:creator>
      <dc:date>2020-06-13T14:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: New User, Code works if run in seperate parts, not if run as  a whole, code/error messages inclu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658279#M197292</link>
      <description>&lt;P&gt;Strongly suggest that you modify the process so that you have typical SAS variable names. You will find that typo errors go way down using variable names like Total_Cost instead of 'Total Cost'n;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 14:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658279#M197292</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-13T14:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: New User, Code works if run in seperate parts, not if run as  a whole, code/error messages inclu</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658280#M197293</link>
      <description>Will adjust code to match SAS variable names. Thanks for the advice.</description>
      <pubDate>Sat, 13 Jun 2020 15:04:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-User-Code-works-if-run-in-seperate-parts-not-if-run-as-a/m-p/658280#M197293</guid>
      <dc:creator>School_UD</dc:creator>
      <dc:date>2020-06-13T15:04:32Z</dc:date>
    </item>
  </channel>
</rss>

