<?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: Create new variables with condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484914#M125922</link>
    <description>&lt;P&gt;Thank you so much, that worked perfectly!&lt;/P&gt;</description>
    <pubDate>Tue, 07 Aug 2018 21:09:46 GMT</pubDate>
    <dc:creator>kmardinian</dc:creator>
    <dc:date>2018-08-07T21:09:46Z</dc:date>
    <item>
      <title>Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484843#M125901</link>
      <description>&lt;P&gt;Hi, I am writing a program where the dataset I am using contains multiple variables with check marks (X) in them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; RAPID&amp;nbsp; WASH&amp;nbsp; POOR&amp;nbsp;&amp;nbsp; OTHER&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&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; X&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; 2&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&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;&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; 1 &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3&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; X&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&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; 3 &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to write a code that whenever SUM equals 2 or 3, another variable is created that lists the variable names that have been check marked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I came up with this, but cannot find a way to make it so that the new variable includes RAPID and POOR for ID #1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data K;&lt;/P&gt;&lt;P&gt;set V (keep=ID SUM RAPID WASH POOR OTHER);&lt;/P&gt;&lt;P&gt;length VQ $1000;&lt;/P&gt;&lt;P&gt;if VQ=2 then do;&lt;/P&gt;&lt;P&gt;if RAPID ne '&amp;nbsp; ' then VQ="Rapid cleaning";&lt;/P&gt;&lt;P&gt;if WASH ne '&amp;nbsp; ' then VQ="Quick Wash";&lt;/P&gt;&lt;P&gt;if POOR ne '&amp;nbsp; ' then VQ='Poor cleaning';&lt;/P&gt;&lt;P&gt;if OTHER ne '&amp;nbsp; ' then VQ="Other';&lt;/P&gt;&lt;P&gt;output; end;&lt;/P&gt;&lt;P&gt;if VQ=3 then do;&lt;/P&gt;&lt;P&gt;if RAPID ne '&amp;nbsp; ' then VQ="Rapid cleaning";&lt;/P&gt;&lt;P&gt;if WASH ne '&amp;nbsp; ' then VQ="Quick Wash";&lt;/P&gt;&lt;P&gt;if POOR ne '&amp;nbsp; ' then VQ='Poor cleaning';&lt;/P&gt;&lt;P&gt;if OTHER ne '&amp;nbsp; ' then VQ="Other';&lt;/P&gt;&lt;P&gt;output; end;&lt;/P&gt;&lt;P&gt;drop RAPID WASH POOR OTHER;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated! Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 17:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484843#M125901</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-08-07T17:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484848#M125903</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139341"&gt;@kmardinian&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I am writing a program where the dataset I am using contains multiple variables with check marks (X) in them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; RAPID&amp;nbsp; WASH&amp;nbsp; POOR&amp;nbsp;&amp;nbsp; OTHER&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&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; X&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; 2&lt;/P&gt;
&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&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;&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; 1 &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3&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; X&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&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; 3 &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Just so I'm 100% clear on what you mean, modify the table and type in the desired output&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 18:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484848#M125903</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-08-07T18:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484851#M125904</link>
      <description>&lt;P&gt;I would like the output to look like the following&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SUM&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; VQ&lt;/P&gt;&lt;P&gt;1&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; 2&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; Rapid, Poor&lt;/P&gt;&lt;P&gt;2&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; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3&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; 3&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; Wash, Poor&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 18:09:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484851#M125904</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-08-07T18:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484852#M125905</link>
      <description>&lt;P&gt;Just so we don't go down a wrong path, what are you planning to do with variable VQ after it is created? Is the goal simply to put this table into&amp;nbsp;some kind of report, or are there additional analyses planned?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 18:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484852#M125905</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-08-07T18:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484853#M125906</link>
      <description>&lt;P&gt;VQ would be used to create a report using Proc report later on in my code&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 18:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484853#M125906</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-08-07T18:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484887#M125911</link>
      <description>&lt;P&gt;An extremely common approach to data like this is to actually read the data so that instead of X or Y or check mark or some other character to read it such that the character of interest in your data is read as a numeric where 1= X, yes, true, selected or whatever the mark means and 0 means not selected, false, no and so on.&lt;/P&gt;
&lt;P&gt;Then your question becomes nearly trivial:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sum = sum(rapid, poor, wash,other);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An example with a custom informat to read a character into numeric and some display formats.&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
invalue check
'X'=1
other=0
;
value rapid
1='Rapid cleaning'
other=' ';
value wash
1='Quick wash'
other=' ';
value poor
1='Poor cleaning'
other=' ';
value other
1='Other'
other=' ';
run;

data example;
  infile datalines dlm=',' dsd;
  informat id $3. rapid wash poor other check.;
  input id rapid wash poor other;
  length vq $100.;
  sum=sum(rapid, wash, poor, other);
  if sum in (2,3) then vq= catx(',',put(rapid,rapid.),put(wash,wash.),put(poor,poor.),put(other,other.));
datalines;
1,X,,X, 
2,X,,, 
3,,X,X, 
4,,,,X
;
run;

&lt;/PRE&gt;
&lt;P&gt;Why might you want to have those values as 1 and 0 you might ask. The SUM of the variable in a procedure such as proc means, summary, tabulate or report would be the number of X's recorded and the Mean would be the percentage chosen for each variable. Also some modeling procedures require a numeric value, most will by default drop records with missing values for any of the variables on the model, class or by statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The custom formats to create the VQ phrase could also work by changing&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;value&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; rapid&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;1&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'Rapid cleaning'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;other=&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;' '&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;to &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;value&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; $rapid&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;X&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;'Rapid cleaning'&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;other=&lt;/FONT&gt;&lt;FONT color="#800080" face="SAS Monospace" size="2"&gt;' '&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;and using the $ version of the format in the put function call.&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="2"&gt;If you want to keep the X then you could use&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;sum=length(catt(rapid, wash,poor,other));&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 20:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484887#M125911</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-07T20:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484906#M125917</link>
      <description>&lt;P&gt;Thank you so much for your help!&lt;BR /&gt;&lt;BR /&gt;i did realize that I misstyped my first post and that it should be whether SUM equals 2 or 3 not VQ (VQ is the new variable I was trying to create). But I will try and adjust the code you have provided me with to make it work!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 20:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484906#M125917</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-08-07T20:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484908#M125918</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I am using a dataset, how would I code it without coding the actual datalines. And also, how would I call the format I've just created?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc format library=work;
invalue check
'X'=1
other=0
;
value rapid
1='Rapid cleaning'
other=' ';
value wash
1='Quick wash'
other=' ';
value poor
1='Poor cleaning'
other=' ';
value other
1='Other'
other=' ';
run;&lt;/PRE&gt;&lt;P&gt;I used the above code and then added the code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data K;&lt;BR /&gt;set V(keep=ID RAPID WASH POOR OTHER);&lt;BR /&gt;length VQ $100;&lt;BR /&gt;vq=vq(RAPID, WASH, POOR, OTHER);&lt;BR /&gt;if sum in (2,3) then vq=catx(',', put(RAPID, RAPID.), put(WASH, WASH.), put(POOR, POOR.),&amp;nbsp; put(OTHER, OTHER.));&lt;BR /&gt;format RAPID RAPID. WASH WASH. POOR POOR. OTHER OTHER.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I seem to be getting this error and note as well:&lt;/P&gt;&lt;P&gt;ERROR 68-185: The function VQ is unknown, or cannot be accessed.&lt;/P&gt;&lt;P&gt;NOTE 484-185: Format $RAPID was not found or could not be loaded&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 20:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484908#M125918</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-08-07T20:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484910#M125920</link>
      <description>&lt;P&gt;This is how I would produce the output you are looking for here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data K;
Set V (Keep = ID Sum Rapid Wash Poor Other);
Length VQ $25;

If Sum &amp;gt; 1 Then Do;

If Rapid = 'X' Then VQ = 'Rapid';
If Wash = 'X' Then VQ = Catx(', ', VQ, 'Wash');
If Poor = 'X' Then VQ = Catx(', ', VQ, 'Poor');
If Other = 'X' Then VQ = Catx(', ', VQ, 'Other');

End;

Keep ID Sum VQ;

Run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 07 Aug 2018 20:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484910#M125920</guid>
      <dc:creator>jdwaterman91</dc:creator>
      <dc:date>2018-08-07T20:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484914#M125922</link>
      <description>&lt;P&gt;Thank you so much, that worked perfectly!&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 21:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484914#M125922</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2018-08-07T21:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create new variables with condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484939#M125928</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;If I am using a dataset, how would I code it without coding the actual datalines.&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If your data set is some form of text file then the INFILE would reference your external file in place of data lines&amp;nbsp;and have appropriate information such as the delimiter. I used a comma but others are possible. Then there would not be any DATALINES in the code to read your external file.&lt;/P&gt;
&lt;P&gt;EACH of the variables to be read using the CHECK informat would have to be indicated. The input statement needs to match the order of your data.&lt;/P&gt;
&lt;P&gt;If you source is a spreadsheet to the easiest would be to&lt;/P&gt;
&lt;P&gt;1) do a file SAVE AS and select CSV (if not spreadsheet skip this)&lt;/P&gt;
&lt;P&gt;2) Use either the import wizard or proc import to bring in the file. Use the option guessingrows with a very large value (number of rows in file is best if possible).&lt;/P&gt;
&lt;P&gt;3) either of the import wizard or proc import will have data step code in the log. COPY that from the log and paste into the editor. You may need to remove line numbers..&lt;/P&gt;
&lt;P&gt;4) change all of the informat statements for variables that likely came have a $1. to the CHECK. informat created that used X for the value.&lt;/P&gt;
&lt;P&gt;5) save the program .&lt;/P&gt;
&lt;P&gt;6) rerun the program to reread the data with the new informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Aug 2018 23:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-new-variables-with-condition/m-p/484939#M125928</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-07T23:01:42Z</dc:date>
    </item>
  </channel>
</rss>

