<?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: Creating a custom zscore function using SAS programming in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-custom-zscore-function-using-SAS-programming/m-p/590822#M169151</link>
    <description>&lt;P&gt;You are attempting to create a "function" that calls a procedure which outputs a data set.&lt;/P&gt;
&lt;P&gt;But somehow you expect to get a value when you call this function.&lt;/P&gt;
&lt;P&gt;A few steps are missing it seems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2019 04:09:14 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-09-23T04:09:14Z</dc:date>
    <item>
      <title>Creating a custom zscore function using SAS programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-custom-zscore-function-using-SAS-programming/m-p/590742#M169122</link>
      <description>&lt;P&gt;I am trying to create a z score function so that it can be used repeatedly anytime I want to calculate the z score.&lt;/P&gt;&lt;P&gt;I know how to calculate the z score, the only problem I have is to make it a function that can be reused.&lt;/P&gt;&lt;P&gt;I am using the cars&amp;nbsp;data set which I will attach to this question.&lt;/P&gt;&lt;P&gt;First I created a library named ztest and imported the dataset;&lt;/P&gt;&lt;P&gt;libname ztest "\Users\Ifeoma\Downloads\newsas";&lt;BR /&gt;proc import datafile = "C:\Users\Ifeoma\Downloads\cars.xlsx"&lt;BR /&gt;out = ztest.zscore&lt;BR /&gt;dbms = xlsx replace;&lt;BR /&gt;getnames = yes;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Here is my code for calculating z score which worked.&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data test(keep = length horsepower mpg_city);&lt;BR /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set ztest.zscore;&lt;BR /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc standard data = test mean = 0 std = 1 out = z_test;&lt;BR /&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;&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; var length horsepower mpg_city;&lt;BR /&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;The data set WORK.Z_TEST has 421 observations and 3 variables.&lt;BR /&gt;NOTE: PROCEDURE STANDARD used (Total process time):&lt;BR /&gt;real-time 0.01 seconds&lt;BR /&gt;CPU time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code to create a z score function which did not work;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc fcmp outlib = ztest.test;&lt;BR /&gt;function get_z(length, horsepower , mpg_city);&lt;BR /&gt;proc standard data = test mean = 0 std = 1 out = z_test;&lt;BR /&gt;var length horsepower mpg_city;&lt;BR /&gt;run;&lt;BR /&gt;options cmplib=ztest.test;&lt;BR /&gt;score = get_z(length, horsepower , mpg_city);&lt;BR /&gt;put score = ;&lt;/P&gt;&lt;P&gt;Here is the error I got;&lt;/P&gt;&lt;P&gt;NOTE: No CMP or C functions found in library ztest.test.&lt;BR /&gt;70 function get_z(length, horsepower , mpg_city);&lt;/P&gt;&lt;P&gt;ERROR: Subroutine 'get_z' was not terminated with ENDSUB.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE FCMP used (Total process time):&lt;BR /&gt;real-time 0.07 seconds&lt;BR /&gt;CPU time 0.04 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to correct this procedure or is there another procedure to use?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Sep 2019 15:45:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-custom-zscore-function-using-SAS-programming/m-p/590742#M169122</guid>
      <dc:creator>Stacy1</dc:creator>
      <dc:date>2019-09-22T15:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a custom zscore function using SAS programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-custom-zscore-function-using-SAS-programming/m-p/590794#M169143</link>
      <description>The way you're currently designing this will not work. You'll need to provide some more requirements about what you're trying to accomplish before we can offer a solution. &lt;BR /&gt;&lt;BR /&gt;You may need a macro instead of a function for example.  Though PROC STANDARD does that anyways so not sure what value you'd get otherwise. &lt;BR /&gt;&lt;BR /&gt;You will not be able to call it in the method you've shown as well, so more specifications are needed.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 23 Sep 2019 01:57:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-custom-zscore-function-using-SAS-programming/m-p/590794#M169143</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-09-23T01:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a custom zscore function using SAS programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-custom-zscore-function-using-SAS-programming/m-p/590822#M169151</link>
      <description>&lt;P&gt;You are attempting to create a "function" that calls a procedure which outputs a data set.&lt;/P&gt;
&lt;P&gt;But somehow you expect to get a value when you call this function.&lt;/P&gt;
&lt;P&gt;A few steps are missing it seems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 04:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-custom-zscore-function-using-SAS-programming/m-p/590822#M169151</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-09-23T04:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a custom zscore function using SAS programming</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-custom-zscore-function-using-SAS-programming/m-p/590868#M169173</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/291684"&gt;@Stacy1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to create a z score function so that it can be used repeatedly anytime I want to calculate the z score.&lt;/P&gt;
&lt;P&gt;I know how to calculate the z score, the only problem I have is to make it a function that can be reused.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc fcmp outlib = ztest.test;&lt;BR /&gt;function get_z(length, horsepower , mpg_city);&lt;BR /&gt;proc standard data = test mean = 0 std = 1 out = z_test;&lt;BR /&gt;var length horsepower mpg_city;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I am not aware that functions in PROC FCMP can include SAS PROC statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is wrong with simply using PROC STDIZE to obtain both the original variables and the zscore in a single data set? I don't see a need for a function/subroutine/macro to do this.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 11:00:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-custom-zscore-function-using-SAS-programming/m-p/590868#M169173</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-09-23T11:00:04Z</dc:date>
    </item>
  </channel>
</rss>

