<?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: Recoding a SAS Character Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270622#M53800</link>
    <description>&lt;P&gt;Your particular case doesn't lend itself to any of the mentioned methods.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your replacing a D with an S, the translate() function is sufficient. Or Substr as indicated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 May 2016 02:11:21 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-05-16T02:11:21Z</dc:date>
    <item>
      <title>Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270613#M53795</link>
      <description>&lt;P&gt;I have a SAS Data Set containing a Character Variable: 'Question' with values as follows:&lt;/P&gt;&lt;P&gt;DQ01, DQ02, DQ03,...,DQ59.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to recode my variable 'Question' so that the values become;&lt;/P&gt;&lt;P&gt;SQ01, SQ02, SQ03,..., SQ59.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I recode the above variable using one or more of the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a. ARRAYs&lt;/P&gt;&lt;P&gt;b. PROC Format&lt;/P&gt;&lt;P&gt;c. Data Steps ( If A then B Statements )&lt;/P&gt;&lt;P&gt;d. Other Constructs such as CASE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2016 23:36:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270613#M53795</guid>
      <dc:creator>JonDickens1607</dc:creator>
      <dc:date>2016-05-15T23:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270617#M53798</link>
      <description>&lt;P&gt;How about this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input question $;
datalines;
DQ01
DQ02
DQ03
;
run;

data want;
set have;
substr(question,1,2)="SQ";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2016 00:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270617#M53798</guid>
      <dc:creator>Miracle</dc:creator>
      <dc:date>2016-05-16T00:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270622#M53800</link>
      <description>&lt;P&gt;Your particular case doesn't lend itself to any of the mentioned methods.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your replacing a D with an S, the translate() function is sufficient. Or Substr as indicated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 02:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270622#M53800</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-16T02:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270624#M53801</link>
      <description>&lt;P&gt;Quick note, there's no CASE within a data step, that's the SQL method for implementing if-then logic.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, your situation is a simple recode there's no need for anything fancy. Here's a demo of the SUBSTR, TRANSLATE, and a CASE statement, though that would get long fast so it's not really a recommended method.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your just interested in all the ways to recode a variable I suggest you search on Lexjansen.com, there's many papers written on how to implement the various ways, as well as why one may be better than another.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
set have;
question2=question;
question1=question;

question = translate(question, 'S', 'D');

substr(question1, 1, 1)='S';

select(question2);
when ('DQ01') question2='SQ01';
when ('DQ02') question2='SQ02';
when ('DQ03') question2='SQ03';
otherwise question2='ERROR';
end;

run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2016 03:26:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270624#M53801</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-16T03:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270643#M53805</link>
      <description>&lt;P&gt;This is something that comes up time and time again. &amp;nbsp;Having many columns is not ideal for any process. &amp;nbsp;It may be useful in an output report, however at all other times working with long data will make your life so much easier. &amp;nbsp;Take your problem, if your data looked like this (long format know as normalised):&lt;/P&gt;
&lt;PRE&gt;data have;
  question="DQ01"; answer="Y"; output;
  question="DQ02"; answer="N"; output;
  question="DQ03"; answer="Y"; output;
run;&lt;/PRE&gt;
&lt;P&gt;Your problem is so simple to achieve:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  substr(question,1,1)="S";
run;
&lt;/PRE&gt;
&lt;P&gt;No need for arrays, couting variables, changing structures etc. a simple statement. &amp;nbsp;This is why programming with Normalised data is far prefereable than working with transposed data - nothing stopping you from transposing the above when you need it for report as the data you program with does not need to look like the output data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Really can't understand where this need to work with transposed data comes from? &amp;nbsp;Most standards that I have seen (take CDISC for instance) all use normalised datasets as its just far easier to work with.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 08:34:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270643#M53805</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-16T08:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270644#M53806</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Thank you for your response to my query.&lt;BR /&gt;&lt;BR /&gt;The reason for working with this specific data structure is as follows;&lt;BR /&gt;&lt;BR /&gt;Three explanatory variables may be useful for predicting the time taken to&lt;BR /&gt;complete a task and one of those variables is a ordinal summary / aggregate&lt;BR /&gt;variable representing the complexity of the task.&lt;BR /&gt;&lt;BR /&gt;Consequently I converted the other explanatory variables and the target&lt;BR /&gt;variable into a summary level using medians at the same level of&lt;BR /&gt;granularity ( By task ).&lt;BR /&gt;&lt;BR /&gt;Unfortunately i had not foreseen the need to merge four files by task and&lt;BR /&gt;the task variables had different names in each data set.&lt;BR /&gt;&lt;BR /&gt;That is why I was exploring recoding methods.&lt;BR /&gt;&lt;BR /&gt;I suppose top down structured programming methods would have prevented this&lt;BR /&gt;problem?&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Mon, 16 May 2016 08:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270644#M53806</guid>
      <dc:creator>JonDickens1607</dc:creator>
      <dc:date>2016-05-16T08:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270645#M53807</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Thank you for your response to my query.&lt;BR /&gt;&lt;BR /&gt;Please refer to my other post in response to a suggestion from another&lt;BR /&gt;member of the community.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Mon, 16 May 2016 08:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270645#M53807</guid>
      <dc:creator>JonDickens1607</dc:creator>
      <dc:date>2016-05-16T08:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270646#M53808</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Thank you for your response to my query.&lt;BR /&gt;&lt;BR /&gt;Please refer to my other post in response to a suggestion from another&lt;BR /&gt;member of the community.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Mon, 16 May 2016 08:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270646#M53808</guid>
      <dc:creator>JonDickens1607</dc:creator>
      <dc:date>2016-05-16T08:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270647#M53809</link>
      <description>&lt;P&gt;Perhaps post some of your data (test) in the form of a datastep (so we can read it in), and what the output should look like. &amp;nbsp;Am not really seeing the picture from the two posts.&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 08:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270647#M53809</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-16T08:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270652#M53810</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Thank you for responding to my query.&lt;BR /&gt;&lt;BR /&gt;Please refer to my other post in which I have explained my data structure&lt;BR /&gt;problem.&lt;BR /&gt;&lt;BR /&gt;An NDA prevents me from providing any more details or data itself.&lt;BR /&gt;&lt;BR /&gt;BTW. The simple solution using SUBSTR works perfectly.&lt;BR /&gt;&lt;BR /&gt;I had tried this solution late last night already but a prior syntax /&lt;BR /&gt;typing error caused a problem which miraculously disappeared after a good&lt;BR /&gt;shower and breakfast this morning.&lt;BR /&gt;&lt;BR /&gt;However, in a more complex observation recoding task, more sophisticated&lt;BR /&gt;solutions are useful to collect into one's toolkit.&lt;BR /&gt;&lt;BR /&gt;Thanks again for everyone who responded to my query.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Mon, 16 May 2016 09:29:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270652#M53810</guid>
      <dc:creator>JonDickens1607</dc:creator>
      <dc:date>2016-05-16T09:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270658#M53812</link>
      <description>&lt;P&gt;We all work under NDA's, I am asking for some test data - which mirrors your structure, and what the output should look like. &amp;nbsp;Something simple such as (which cover each occurence):&lt;/P&gt;
&lt;PRE&gt;data have1;
  var1="abc"; var2=23; output;
  var1=...;
run;&lt;/PRE&gt;
&lt;P&gt;For each of the datasets involved. &amp;nbsp;The reason is I can't see the picture of what is to happen and from what. &amp;nbsp;You say you have a variable called Question, then the values go down the dataset yes? &amp;nbsp;So none of your original questions match. &amp;nbsp;You later mention that you need to merge datasets - there is not indication of what each of the datasets look like, so can't tell you how to do it. &amp;nbsp;If they all have QUESTION and RESULT only, then you might not need to change the variable at all:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  COALESCE(A.QUESTION,B.QUESTION...) as QUESTION,
              A.RESULT as RESULT_A,
              B.RESULT as RESULT_B,
              ...
  from    HAVE A
  full join HAVE B
  on        substr(A.QUESTION,2)=substr(B.QUESTION,2)
...
quit;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2016 10:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270658#M53812</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-16T10:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270675#M53816</link>
      <description>Thank you for your e-mail.&lt;BR /&gt;&lt;BR /&gt;I have attached a document which provides more information.&lt;BR /&gt;&lt;BR /&gt;Let me know if this is sufficient.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Mon, 16 May 2016 12:21:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270675#M53816</guid>
      <dc:creator>JonDickens1607</dc:creator>
      <dc:date>2016-05-16T12:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270679#M53817</link>
      <description>&lt;P&gt;Sorry, no attachment. &amp;nbsp;I wouldn't be able to download certain files due to security risk anyways, and the other files I wouldn't type in. &amp;nbsp;Please see this post where Reeza provides information on how to create a datastep for test data.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 12:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270679#M53817</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-16T12:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding a SAS Character Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270771#M53844</link>
      <description>Extract from the Exploratory Data Analysis Code&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/* use proc freq to compute the number of levels for each question: task&lt;BR /&gt;complexity */&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PROC FREQ&lt;BR /&gt;&lt;BR /&gt;DATA = WORK.DATA12345C NLEVELS ;&lt;BR /&gt;&lt;BR /&gt;TABLES SQ01 - SQ59 / NOCOL ;&lt;BR /&gt;&lt;BR /&gt;ODS OUTPUT NLEVELS = WORK.QUESTLEVELS_1 ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/* sort (for future merge) and simplify the output data set produced by&lt;BR /&gt;proc freq */&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PROC SORT&lt;BR /&gt;&lt;BR /&gt;DATA = WORK.QUESTLEVELS_1&lt;BR /&gt;&lt;BR /&gt;OUT = WORK.QUESTLEVELS_2&lt;BR /&gt;&lt;BR /&gt;( DROP = TableVarLabel ) EQUALS ;&lt;BR /&gt;&lt;BR /&gt;BY TABLEVAR ; /* question – task number */&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/* explanatory variables: complexity of the task ( levels ) PER QUESTION&lt;BR /&gt;&lt;BR /&gt;distance function 1 and distance&lt;BR /&gt;function2 */&lt;BR /&gt;&lt;BR /&gt;/* target variable: DURATION PER QUESTION ( THE complexity of the&lt;BR /&gt;task ) */&lt;BR /&gt;&lt;BR /&gt;/* source data sets: QUESTLEVELS and DATA345DDSS */&lt;BR /&gt;&lt;BR /&gt;/* PROC MEANS produces the ODS TABLE summary for USE IN the output data set&lt;BR /&gt;*/&lt;BR /&gt;&lt;BR /&gt;/* exploratory data analysis for each of the three explanatory variables */&lt;BR /&gt;&lt;BR /&gt;/* x1 = questlevels ; x2 = DL01 - DL59 ; x3 = DE01 - DE59: target variable&lt;BR /&gt;= duration */&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PROC MEANS&lt;BR /&gt;&lt;BR /&gt;DATA = WORK.DATA345DDSS STACKODS&lt;BR /&gt;&lt;BR /&gt;N MIN P25 MEDIAN MEAN P75 MAX MAXDEC = 2;&lt;BR /&gt;&lt;BR /&gt;VAR DQ01 - DQ59 ; /* compute median duration per question: sq01 to&lt;BR /&gt;sq59 */&lt;BR /&gt;&lt;BR /&gt;ODS OUTPUT SUMMARY = WORK.DATA3DP_STATS ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PROC MEANS&lt;BR /&gt;&lt;BR /&gt;DATA = WORK.DATA345DDSS STACKODS&lt;BR /&gt;&lt;BR /&gt;N MIN P25 MEDIAN MEAN P75 MAX MAXDEC = 2;&lt;BR /&gt;&lt;BR /&gt;VAR DL01 - DL59 ; /* compute median distance 1 per question: sq01 to&lt;BR /&gt;sq59 */&lt;BR /&gt;&lt;BR /&gt;ODS OUTPUT SUMMARY = WORK.DATADF1_STATS ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PROC MEANS&lt;BR /&gt;&lt;BR /&gt;DATA = WORK.DATA345DDSS STACKODS&lt;BR /&gt;&lt;BR /&gt;N MIN P25 MEDIAN MEAN P75 MAX MAXDEC = 2;&lt;BR /&gt;&lt;BR /&gt;VAR DE01 - DE59 ; /* compute median distance 2 per question: sq01 to&lt;BR /&gt;sq59 */&lt;BR /&gt;&lt;BR /&gt;ODS OUTPUT SUMMARY = WORK.DATADF2_STATS ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;DATA WORK.DATA3DPM_STATS&lt;BR /&gt;&lt;BR /&gt;( RENAME =( VARIABLE = QUESTION MEDIAN = DURATION ) ) ;&lt;BR /&gt;&lt;BR /&gt;SET WORK.DATA3DP_STATS ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA WORK.DATADF1M_STATS&lt;BR /&gt;&lt;BR /&gt;( RENAME =( VARIABLE = QUESTION MEDIAN = DISTANCE1 ) ) ;&lt;BR /&gt;&lt;BR /&gt;SET WORK.DATADF1_STATS ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA WORK.DATADF2M_STATS&lt;BR /&gt;&lt;BR /&gt;( RENAME =( VARIABLE = QUESTION MEDIAN = DISTANCE2 ) ) ;&lt;BR /&gt;&lt;BR /&gt;SET WORK.DATADF2_STATS ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA WORK.QUESTLEVELSM&lt;BR /&gt;&lt;BR /&gt;( RENAME =( TABLEVAR = QUESTION NLEVELS_1 = NLEVELS ) ) ;&lt;BR /&gt;&lt;BR /&gt;SET WORK.QUESTLEVELS ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/* CHANGE THE VALUES OF THE QUESTION VARIABLE TO MATCH SQ01 TO SQ59 ALL 4&lt;BR /&gt;DATA SETS */&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA DATA3DPQ_STATS ; /* No Quotes: DQ01-DQ59 TO SQ01-SQ59 */&lt;BR /&gt;&lt;BR /&gt;SET DATA3DPM_STATS ;&lt;BR /&gt;&lt;BR /&gt;SUBSTR(QUESTION,1,2)="SQ";&lt;BR /&gt;&lt;BR /&gt;RUN ;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA DATADF1Q_STATS ; /* Single Quotes: DL01-DL59 TO SQ01-SQ59 */&lt;BR /&gt;&lt;BR /&gt;SET DATADF1M_STATS ;&lt;BR /&gt;&lt;BR /&gt;SUBSTR(QUESTION,1,2)="SQ";&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA DATADF2Q_STATS ; /* Double Quotes: DE01-DE59 TO SQ01-SQ59 */&lt;BR /&gt;&lt;BR /&gt;SET DATADF2M_STATS ;&lt;BR /&gt;&lt;BR /&gt;SUBSTR(QUESTION,1,2)="SQ";&lt;BR /&gt;&lt;BR /&gt;RUN ;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PROC SORT&lt;BR /&gt;&lt;BR /&gt;DATA = WORK.DATA3DPQ_STATS&lt;BR /&gt;&lt;BR /&gt;OUT = WORK.DATA3DPS&lt;BR /&gt;&lt;BR /&gt;( DROP = LABEL N MIN P25 MEAN P75 MAX )EQUALS ;&lt;BR /&gt;&lt;BR /&gt;BY QUESTION ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PROC SORT&lt;BR /&gt;&lt;BR /&gt;DATA = WORK.DATADF1Q_STATS&lt;BR /&gt;&lt;BR /&gt;OUT = WORK.DATADF1S&lt;BR /&gt;&lt;BR /&gt;( DROP = LABEL N MIN P25 MEAN P75 MAX )EQUALS ;&lt;BR /&gt;&lt;BR /&gt;BY QUESTION ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;PROC SORT&lt;BR /&gt;&lt;BR /&gt;DATA = WORK.DATADF2Q_STATS&lt;BR /&gt;&lt;BR /&gt;OUT = WORK.DATADF2S&lt;BR /&gt;&lt;BR /&gt;( DROP = LABEL N MIN P25 MEAN P75 MAX )EQUALS ;&lt;BR /&gt;&lt;BR /&gt;BY QUESTION ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PROC SORT&lt;BR /&gt;&lt;BR /&gt;DATA = WORK.QUESTLEVELSM&lt;BR /&gt;&lt;BR /&gt;OUT = WORK.QUESTLEVELSS&lt;BR /&gt;&lt;BR /&gt;( DROP = NLEVELS_2 NLEVELS_3 )EQUALS ;&lt;BR /&gt;&lt;BR /&gt;BY QUESTION ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA QUIZDATA ;&lt;BR /&gt;&lt;BR /&gt;MERGE QUESTLEVELSS DATA3DPS DATADF1S DATADF2S;&lt;BR /&gt;&lt;BR /&gt;BY QUESTION ;&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The final required data set looks like this :&lt;BR /&gt;&lt;BR /&gt;[image: Inline images 1]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Mon, 16 May 2016 19:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-a-SAS-Character-Variable/m-p/270771#M53844</guid>
      <dc:creator>JonDickens1607</dc:creator>
      <dc:date>2016-05-16T19:47:11Z</dc:date>
    </item>
  </channel>
</rss>

