<?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: Words in a range in if, then statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890364#M39606</link>
    <description>Unfortunately they come from other calculations. I cannot change them. I have to use C, P and F.</description>
    <pubDate>Tue, 22 Aug 2023 11:25:17 GMT</pubDate>
    <dc:creator>NewUsrStat</dc:creator>
    <dc:date>2023-08-22T11:25:17Z</dc:date>
    <item>
      <title>Words in a range in if, then statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890332#M39601</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how can I write in "if, then" statement: if a condition = x then columnx = wordC1 wordC2 wordC3 wordC4 wordC5 wordC6 in a compact way? Let say:&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if condition = 0 then columnx = wordC1-wordC6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;suppose to have the following:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ID&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;gt;&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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired output:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; wordC1&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;wordC2&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;wordC3&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;wordP1&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;wordP2&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;wordP3&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;wordP4&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;wordF1&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;wordF2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ID = 6 then&amp;nbsp;wordC* (from 1 to 3 because there are 3 rows having 6 in ID column)&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ID = 3 then&amp;nbsp;wordP* (from 1 to 4 because there are 4 rows having 2 in ID column)&lt;/P&gt;
&lt;P&gt;&amp;gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ID = 1 then&amp;nbsp;wordF* (from 1 to 2 because there are 2 rows having 1 in ID column)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 10:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890332#M39601</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2023-08-22T10:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Words in a range in if, then statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890337#M39602</link>
      <description>&lt;P&gt;How do you want the words to be concatenated? Blanks, underlines, hyphens, nothing in between?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 09:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890337#M39602</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-08-22T09:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Words in a range in if, then statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890339#M39603</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   length column1 $256.;
   input var1 $ var2 $ var3 $ var4 $ var5 $ var6 $;
   if 1 then column1 = catx(" ", of var1-var6);
   put column1=;
   cards;
word1
word2
word3
word4
word5
word6
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Aug 2023 09:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890339#M39603</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2023-08-22T09:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: Words in a range in if, then statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890358#M39604</link>
      <description>I edited the question with example to explain better the desired output</description>
      <pubDate>Tue, 22 Aug 2023 10:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890358#M39604</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2023-08-22T10:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Words in a range in if, then statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890362#M39605</link>
      <description>&lt;P&gt;Where do the C&amp;nbsp; P and F come from? There is no obvious reason to insert those characters. Is there another rule you haven't mentioned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest you provide an actual example of your data set as I think there may be more than one or two things missing in your description. The data should be in the form of a working data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &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; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 11:11:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890362#M39605</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-22T11:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: Words in a range in if, then statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890364#M39606</link>
      <description>Unfortunately they come from other calculations. I cannot change them. I have to use C, P and F.</description>
      <pubDate>Tue, 22 Aug 2023 11:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890364#M39606</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2023-08-22T11:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Words in a range in if, then statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890374#M39607</link>
      <description>&lt;P&gt;You can use a format (or similar) to store the mapping from ID= 1, 2,6 to C,P, F.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your data are grouped by ID , you can use by-group processing to count records in each group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I think something like below should work, if I'm understanding what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input id ;
  cards ;
6
6
6
2
2
2
2
1
1
;
run ;

proc format ;
  value type
   6='C'
   2='P'
   1='F'
  ;
run ;

data want ;
  set have ;
  by id notsorted ;

  if first.id then _count=0 ;
  _count++1 ;

  word=cats("word",put(id,type.),_count) ;

  drop _count ;
run ;

proc print data=want ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Returns:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs    id     word

 1      6    wordC1
 2      6    wordC2
 3      6    wordC3
 4      2    wordP1
 5      2    wordP2
 6      2    wordP3
 7      2    wordP4
 8      1    wordF1
 9      1    wordF2
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 11:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890374#M39607</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-08-22T11:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Words in a range in if, then statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890375#M39608</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134532"&gt;@NewUsrStat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Unfortunately they come from other calculations. I cannot change them. I have to use C, P and F.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If they are calculated then you should share the calculation as that is needed as part of the solution of your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2023 11:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890375#M39608</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-22T11:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Words in a range in if, then statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890393#M39609</link>
      <description>Thank you very much! It is what I was looking for!</description>
      <pubDate>Tue, 22 Aug 2023 14:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Words-in-a-range-in-if-then-statement/m-p/890393#M39609</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2023-08-22T14:31:07Z</dc:date>
    </item>
  </channel>
</rss>

