<?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 How can I separate values from one variable in order to use the new vars for calculation? in SAS Software for Learning Community</title>
    <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-separate-values-from-one-variable-in-order-to-use-the/m-p/844516#M788</link>
    <description>&lt;P&gt;&lt;FONT size="2"&gt;I am (SUPER NEW) using SAS Studio ODA, 9.4,&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I have a data set that I have cleaned and reduced from 5000 obs to 445, and now have the following variables: Branch AVGLoanAmt AVGPrice MedCreditScore&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Within the Branch variable I have 5 values (1-5).(sorted by desc Branch)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I need to calc each Branch by the Count, AVGLoanAmt,AVGPrice, and MedCreditScore. PER Branch&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;**(Branch has Labels Branch(1=LIV924, 2=STV408, 3=SLO805, 4=GLN626, 5=COR760)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I have not used the Labels to create new variables, I have only tried PROC FREQ, PROC MEANS and PROC PRINT to break the data set up in order to do the various calcs for one table.)**&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Here is the exact question asked and my last code:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;&lt;EM&gt;Create a table that calculates the count, mean loan amount, mean home price, and median credit score&lt;/EM&gt;,&lt;U&gt; by branch&lt;/U&gt;&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Everything I have tried is still giving me multiple rows of data with each Branch. And I have to do a PP Presentation for each step, as well, so I know there are possibly more steps than necessary.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;DATA want;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SET have;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;KEEP Branch LoanAmt Price CreditScore LoanApproved PercentDown;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;WHERE PercentDown &amp;lt; 0.05;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;DATA want;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SET have;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;WHERE LoanApproved = 1; IF LoanApproved = 0 THEN DELETE;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;DATA want;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SET have;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;AVGLoanAmt = Mean(LoanAmt);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;AVGPrice = Mean(Price);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;MedCreditScore = Median(CreditScore);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Format AVGLoanAmt AVGPrice Dollar16.2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;FORMAT MedCreditScore 3.;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;KEEP Branch AVGLoanAmt AVGPrice MedCreditScore;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;PROC SORT data=have OUT= Want;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;By DESCENDING Branch descending AVGLoanAmt descending AVGPrice descending MedCreditScore;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Then I get stuck.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really just need to see how to separate and then calculate per branch (Branch1-Branch5) per argument.&lt;/P&gt;&lt;P&gt;ANY HELP WOULD BE SO VERY APPRECIATED!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2022 22:18:36 GMT</pubDate>
    <dc:creator>KateBA715</dc:creator>
    <dc:date>2022-11-15T22:18:36Z</dc:date>
    <item>
      <title>How can I separate values from one variable in order to use the new vars for calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-separate-values-from-one-variable-in-order-to-use-the/m-p/844516#M788</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;I am (SUPER NEW) using SAS Studio ODA, 9.4,&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I have a data set that I have cleaned and reduced from 5000 obs to 445, and now have the following variables: Branch AVGLoanAmt AVGPrice MedCreditScore&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Within the Branch variable I have 5 values (1-5).(sorted by desc Branch)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I need to calc each Branch by the Count, AVGLoanAmt,AVGPrice, and MedCreditScore. PER Branch&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;**(Branch has Labels Branch(1=LIV924, 2=STV408, 3=SLO805, 4=GLN626, 5=COR760)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I have not used the Labels to create new variables, I have only tried PROC FREQ, PROC MEANS and PROC PRINT to break the data set up in order to do the various calcs for one table.)**&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Here is the exact question asked and my last code:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;&lt;EM&gt;Create a table that calculates the count, mean loan amount, mean home price, and median credit score&lt;/EM&gt;,&lt;U&gt; by branch&lt;/U&gt;&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Everything I have tried is still giving me multiple rows of data with each Branch. And I have to do a PP Presentation for each step, as well, so I know there are possibly more steps than necessary.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;DATA want;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SET have;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;KEEP Branch LoanAmt Price CreditScore LoanApproved PercentDown;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;WHERE PercentDown &amp;lt; 0.05;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;DATA want;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SET have;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;WHERE LoanApproved = 1; IF LoanApproved = 0 THEN DELETE;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;DATA want;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;SET have;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;AVGLoanAmt = Mean(LoanAmt);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;AVGPrice = Mean(Price);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;MedCreditScore = Median(CreditScore);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;Format AVGLoanAmt AVGPrice Dollar16.2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;FORMAT MedCreditScore 3.;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;KEEP Branch AVGLoanAmt AVGPrice MedCreditScore;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;PROC SORT data=have OUT= Want;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;By DESCENDING Branch descending AVGLoanAmt descending AVGPrice descending MedCreditScore;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" size="2"&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Then I get stuck.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really just need to see how to separate and then calculate per branch (Branch1-Branch5) per argument.&lt;/P&gt;&lt;P&gt;ANY HELP WOULD BE SO VERY APPRECIATED!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 22:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-separate-values-from-one-variable-in-order-to-use-the/m-p/844516#M788</guid>
      <dc:creator>KateBA715</dc:creator>
      <dc:date>2022-11-15T22:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I separate values from one variable in order to use the new vars for calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-separate-values-from-one-variable-in-order-to-use-the/m-p/844525#M789</link>
      <description>&lt;P&gt;Your requirement:&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;&lt;EM&gt;Create a table that calculates the count, mean loan amount, mean home price, and median credit score&lt;/EM&gt;,&lt;U&gt; by branch&lt;/U&gt;&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;does not have any requirement for &lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;FONT color="#000000"&gt;LoanApproved. So why is it included in any of your code? Or&amp;nbsp;&lt;FONT face="courier new,courier" size="2"&gt;PercentDown&lt;/FONT&gt;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;FONT color="#000000"&gt;You also are creating two different data "want" and the second one replaces the first. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;FONT color="#000000"&gt;This code:&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;DATA want;
SET have;
AVGLoanAmt = Mean(LoanAmt);
AVGPrice = Mean(Price);&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;FONT color="#000000"&gt;Is calculating the "mean" of a single observation and one variable, i.e. the result is the same as LoanAmt.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;FONT color="#000000"&gt;It would help to provide actual example data.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;FONT color="#000000"&gt;Per Branch would typically mean use of a BY or Class variable, depending on the procedure chosen.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;FONT color="#000000"&gt;By "table" do you mean a data set for the result or a report that people read?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;&lt;FONT color="#000000"&gt;Proc means can likely do both with depending on options. This creates a data set.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;Proc means data=have nway noprint;
   class branch;
   var loanamt creditscore price;
  output out=want mean(loanamt price)=AvgLoanamt AvgPrice
                            median(creditscore)=MedCreditScore
  ;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Nov 2022 22:50:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-separate-values-from-one-variable-in-order-to-use-the/m-p/844525#M789</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-15T22:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: How can I separate values from one variable in order to use the new vars for calculation?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-separate-values-from-one-variable-in-order-to-use-the/m-p/844531#M790</link>
      <description>What tools have you learned to create summaries? Proc means/summary/univariate? A data step (I suspect not?) Summary Task?&lt;BR /&gt;If programming:&lt;BR /&gt;&lt;A href="https://www.listendata.com/2015/01/sas-detailed-explanation-of-proc-means.html" target="_blank"&gt;https://www.listendata.com/2015/01/sas-detailed-explanation-of-proc-means.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If tasks:&lt;BR /&gt;&lt;A href="https://video.sas.com/detail/video/5537540644001/the-summary-statistics-task-in-sas%C2%AE-studio?autoStart=true&amp;amp;q=summary%20task" target="_blank"&gt;https://video.sas.com/detail/video/5537540644001/the-summary-statistics-task-in-sas%C2%AE-studio?autoStart=true&amp;amp;q=summary%20task&lt;/A&gt;</description>
      <pubDate>Tue, 15 Nov 2022 23:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-can-I-separate-values-from-one-variable-in-order-to-use-the/m-p/844531#M790</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-15T23:09:17Z</dc:date>
    </item>
  </channel>
</rss>

