<?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: DATA REPLACE VALUES WITH SCORES in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/384670#M11613</link>
    <description>&lt;P&gt;Thank you very much. The exercise code works well in my SAS. It should work on my data.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Aug 2017 16:06:46 GMT</pubDate>
    <dc:creator>JinboZhao</dc:creator>
    <dc:date>2017-08-01T16:06:46Z</dc:date>
    <item>
      <title>DATA REPLACE VALUES WITH SCORES</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/378070#M11511</link>
      <description>&lt;P&gt;Hi SAS,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set which contains over 30 character and numeric variables. Based on this dataset, I generate a scorecard. Now, I want to replace each variable's value with the score I got.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is part of my dataset:&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;DAYS&lt;/TD&gt;&lt;TD&gt;GRADE&lt;/TD&gt;&lt;TD&gt;REMAINING_PERIOD&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;2A&lt;/TD&gt;&lt;TD&gt;5.23&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;2C&l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;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;SCORE TABLE&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;DAYS&lt;/TD&gt;&lt;TD&gt;GRADE&lt;/TD&gt;&lt;TD&gt;REMAINING_PERIOD&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;-4&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;18&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;55&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can do it using DATA, IF, ELSE IF, ELSE, RUN. But since I have more than 150 groups in my scorecard, it is really a time-consuming work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could any expert suggest me an easier and time-consuming way? I am thing maybe I can use some REPLACE procedure, but not familiar with it. Could you help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 11:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/378070#M11511</guid>
      <dc:creator>JinboZhao</dc:creator>
      <dc:date>2017-07-21T11:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: DATA REPLACE VALUES WITH SCORES</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/378077#M11512</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately I don't see a simpler way. &amp;nbsp;Your logical conditions are quite variaed and use multiple variables, if it was just one variable, then you could apply a format, however that is not the case. &amp;nbsp;You could perhaps save a bit of typing by using select syntax:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  select;
    when(2 &amp;lt;= input(days,best.) &amp;lt; 5) then scorecard="12";
    ...
    when(grade in ("2A","2C","3A") then scorecard=6;
...
    otherwise;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jul 2017 11:20:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/378077#M11512</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-21T11:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: DATA REPLACE VALUES WITH SCORES</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/378135#M11518</link>
      <description>&lt;P&gt;You could conceivably create a set of formats based on your SCORECARD data. &amp;nbsp;That's work, but perhaps not as much work. &amp;nbsp;You would begin by creating two SAS data sets (one for numeric values, one for character values). &amp;nbsp;For numeric variables, LABEL would be numeric:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Variable &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Start &amp;nbsp; End &amp;nbsp; Label&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;DAYS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; 12&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;DAYS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; -4&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;DAYS &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6 &amp;nbsp; &amp;nbsp; &amp;nbsp;8 &amp;nbsp; &amp;nbsp; &amp;nbsp;7&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;REMAINING_PERIOD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4.66 &amp;nbsp; &amp;nbsp;9.28 &amp;nbsp; 13&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;REMAINING_PERIOD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9.28 &amp;nbsp; 11.65 &amp;nbsp; 18&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if that would be simpler than what you have now. &amp;nbsp;It's actually more complex than this, since a fifth variable needs to be added. &amp;nbsp;SAS needs to be told that 9.28 exactly belongs in the "18" category, not the "13" category. &amp;nbsp;And when it comes to the character fields, separate lines are required for each value (2A, 2C, and 3A for example all need to go on separate lines as the value of START).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is simpler than what you have now (difficult to tell from here), the remaining programming would be relatively easy. &amp;nbsp;But at least y ou have a choice to think about.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 13:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/378135#M11518</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-21T13:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: DATA REPLACE VALUES WITH SCORES</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/378450#M11531</link>
      <description>&lt;P&gt;Now THAT's an interesting one!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an option, very complicated, but might be both reasonably time-saving and able to be changed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, assume we input your data, I'm naming the dataset "Have":&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ID &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; DAYS &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; GRADE $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; REMAINING_PERIOD &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ID DAYS GRADE REMAINING_PERIOD;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;1 5 2A 5.23&lt;/P&gt;
&lt;P&gt;2 6 2C 10.95&lt;/P&gt;
&lt;P&gt;3 8 2D 20.22&lt;/P&gt;
&lt;P&gt;4 3 1C .&lt;/P&gt;
&lt;P&gt;5 4 2B 8.66&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, we input your specs for transformation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ScorecardSpecs;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Variable $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;32&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Group &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Label $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;128&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; ScorecardPoints &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;8&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Variable Group Label &amp;amp;&amp;amp; ScorecardPoints;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;DAYS 2 2&amp;lt;= DAYS&amp;lt; 5 12&lt;/P&gt;
&lt;P&gt;DAYS 3 5&amp;lt;= DAYS&amp;lt; 6 -4&lt;/P&gt;
&lt;P&gt;DAYS 4 6&amp;lt;= DAYS&amp;lt; 9 7&lt;/P&gt;
&lt;P&gt;GRADE 1 2A, 2C, 3A 6&lt;/P&gt;
&lt;P&gt;GRADE 2 2D 55&lt;/P&gt;
&lt;P&gt;GRADE 3 1C, 2B, 3B, _MISSING_, _UNKNOWN_ 6&lt;/P&gt;
&lt;P&gt;GRADE 4 0, 4 8&lt;/P&gt;
&lt;P&gt;REMAINING_PERIOD 3 4.66&amp;lt;= REMAINING_PERIOD&amp;lt; 9.28 13&lt;/P&gt;
&lt;P&gt;REMAINING_PERIOD 4 9.28&amp;lt;= REMAINING_PERIOD&amp;lt; 11.65 18&lt;/P&gt;
&lt;P&gt;REMAINING_PERIOD 5 11.65&amp;lt;= REMAINING_PERIOD&amp;lt; 23.32 9&lt;/P&gt;
&lt;P&gt;REMAINING_PERIOD 5 REMAINING_PERIOD = _MISSING_ 9&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note the two spaces after each value of "Label".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now this is where things get weird. I'm just doing a first-level implementation, as a proof of concept. In this, the macro Days writes out the transformations needed for variable "DAYS". Then the macro is run, and generates the code. Finally, the data step creates dataset Want by including in the transformation. (I'm creating a variable NewDays, so you can see the original and the derived, but this is easy to change).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; SpecVar = DAYS;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;&lt;I&gt;Days&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;file &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'C:...\GenDays.sas'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;length CodeLine $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;512&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;set ScoreCardSpecs;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;if variable = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;SpecVar."&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;then do;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;CodeLine = catx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;" "&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"if"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, Label, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"then NewDays ="&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, ScoreCardPoints, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;";"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;put CodeLine;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;Days&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%include&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="2"&gt;'C:...\GenDays.sas'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems to work for this variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To make this reasonable efficient to code, I was thinking the second-level implementation would be to have a macro that would generate all of the transformations of one type, another to do the transformations of another type, etc. This is where I don't know how many transformation "types" you have. In your post, it looks like DAYS and REMAINING_PERIOD are one type, and GRADE is another.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second question, are you comfortable with this level of complexity?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before I do any more, let me know if this is going in a reasonable direction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jul 2017 17:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/378450#M11531</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-07-22T17:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: DATA REPLACE VALUES WITH SCORES</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/378576#M11535</link>
      <description>&lt;P&gt;It looks to me like you have code generation problem.&lt;/P&gt;
&lt;P&gt;Do you really want to generate variables that use the same names as the input data? &amp;nbsp;Because it looks like all of your scores are numeric and your input variables are mixed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably just need to beef up your metadata (scorecard) so that it contains all of the information you need to generate the code to compute the score. &amp;nbsp;For example you might want to either include a variable to tell if the source variable is character or numeric. &amp;nbsp;Or at least populate the values of the character variables with quotes so that the generated code will be valid SAS syntax. So perhaps something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data score_meta ;
  length var $32 order 8 condition $200 points 8;
  infile cards dsd dlm='|' ; 
  input var order condition points;
cards;
DAYS|2|2&amp;lt;= DAYS&amp;lt; 5|12
DAYS|3|5&amp;lt;= DAYS&amp;lt; 6|-4
DAYS|4|6&amp;lt;= DAYS&amp;lt; 9|7
GRADE|1|grade in ('2A' '2C' '3A')|6
GRADE|2|grade='2D'|55
GRADE|3|grade in ('1C' '2B' '3B' '_MISSING_' '_UNKNOWN_')|6
GRADE|4|grade in ('0' '4')|8
REMAINING_PERIOD|3|4.66&amp;lt;= REMAINING_PERIOD&amp;lt; 9.28|13
REMAINING_PERIOD|4|9.28&amp;lt;= REMAINING_PERIOD&amp;lt; 11.65|18
REMAINING_PERIOD|5|11.65&amp;lt;= REMAINING_PERIOD&amp;lt; 23.32|9
REMAINING_PERIOD|5|REMAINING_PERIOD is null|9
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you could use that to generate an SQL statement use a simple data _null_ step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set score_meta end=eof;
  by var order ;
  file code ;
  if _n_=1 then put
/ 'create table want as'
/ '  select id'
  ;
  if first.var then put '      , case' ;
  put '        when ('  condition ') then ' points ;
  if last.var  then put '        end as ' var ;
  if eof then put
  '  from have'
/ ';'
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which you could then execute using %INCLUDE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
%include code / source2 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So for the metadata I posted above the SQL code would look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table want as
  select id
      , case
        when (2&amp;lt;= DAYS&amp;lt; 5 ) then 12
        when (5&amp;lt;= DAYS&amp;lt; 6 ) then -4
        when (6&amp;lt;= DAYS&amp;lt; 9 ) then 7
        end as DAYS
      , case
        when (grade in ('2A' '2C' '3A') ) then 6
        when (grade='2D' ) then 55
        when (grade in ('1C' '2B' '3B' '_MISSING_' '_UNKNOWN_') ) then 6
        when (grade in ('0' '4') ) then 8
        end as GRADE
      , case
        when (4.66&amp;lt;= REMAINING_PERIOD&amp;lt; 9.28 ) then 13
        when (9.28&amp;lt;= REMAINING_PERIOD&amp;lt; 11.65 ) then 18
        when (11.65&amp;lt;= REMAINING_PERIOD&amp;lt; 23.32 ) then 9
        when (REMAINING_PERIOD is null ) then 9
        end as REMAINING_PERIOD
  from have
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 03:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/378576#M11535</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-24T03:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: DATA REPLACE VALUES WITH SCORES</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/384622#M11609</link>
      <description>&lt;P&gt;Hi, sorry to reply you so late.&lt;/P&gt;&lt;P&gt;This code does not work well on my SAS, it always say, the FILE WORK.HAVE.DATA does not exist.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could not find the reason, could you help me?&lt;/P&gt;&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 14:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/384622#M11609</guid>
      <dc:creator>JinboZhao</dc:creator>
      <dc:date>2017-08-01T14:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: DATA REPLACE VALUES WITH SCORES</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/384631#M11610</link>
      <description>&lt;P&gt;If you have an error you need to post the log so that the error can be seen in context.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most likely you have copied example code from the discussion and not replaced the generic dataset name that was used to show the structure of the code you need with the name of your actual dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If is common to post code in the form.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
   ...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;since we are not running SAS on your machine and so do not have access to your datasets. You just need to adapt the code to work for your situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 14:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/384631#M11610</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-01T14:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: DATA REPLACE VALUES WITH SCORES</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/384670#M11613</link>
      <description>&lt;P&gt;Thank you very much. The exercise code works well in my SAS. It should work on my data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2017 16:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/DATA-REPLACE-VALUES-WITH-SCORES/m-p/384670#M11613</guid>
      <dc:creator>JinboZhao</dc:creator>
      <dc:date>2017-08-01T16:06:46Z</dc:date>
    </item>
  </channel>
</rss>

