<?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 progressive variable by another variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-progressive-variable-by-another-variable/m-p/886774#M350395</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446299"&gt;@boshmers&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome to the SAS Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's AN answer to your question (it's not THE answer as there are always many alternatives to achieve the same).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know if it's important to restore the original sort order of the clients. If so, just let me know ... then we fix that too !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have0;
input id_client	n_try outcome $;
datalines;
21 1 O
21 2 N
53 1 O
53 2 O
53 3 Y
17 1 Y
17 2 Y
17 3 N
17 4 O
; 

PROC SORT data=have0 out=have1;
 by id_client n_try;
run;

data want;
 LENGTH pattern $ 50;
 set have1;
 retain pattern;
 by id_client;
 if first.id_client then pattern="";
 pattern=strip(pattern) !! ' ' !! strip(outcome);
run;

proc print; run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;BR,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jul 2023 09:23:02 GMT</pubDate>
    <dc:creator>sbxkoenk</dc:creator>
    <dc:date>2023-07-28T09:23:02Z</dc:date>
    <item>
      <title>create progressive variable by another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-progressive-variable-by-another-variable/m-p/886771#M350394</link>
      <description>&lt;P&gt;Hello, this is my first post here. Thank you in advance for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have this datset where id_client is the identifier for my clients, n_try is the numer of times i've tryed to contact them for a purchase proposal anche outcome is Y for "accepted", N is "did not accept" and O is for "did not answered the phone"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id_client&lt;/TD&gt;&lt;TD&gt;n_try&lt;/TD&gt;&lt;TD&gt;outcome&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;O&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;21&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;N&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;53&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;O&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;53&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;O&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;53&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&g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Y&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;YY&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;N&lt;/TD&gt;&lt;TD&gt;YYN&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;O&lt;/TD&gt;&lt;TD&gt;YYNO&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 09:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-progressive-variable-by-another-variable/m-p/886771#M350394</guid>
      <dc:creator>boshmers</dc:creator>
      <dc:date>2023-07-28T09:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: create progressive variable by another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-progressive-variable-by-another-variable/m-p/886774#M350395</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446299"&gt;@boshmers&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Welcome to the SAS Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's AN answer to your question (it's not THE answer as there are always many alternatives to achieve the same).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know if it's important to restore the original sort order of the clients. If so, just let me know ... then we fix that too !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have0;
input id_client	n_try outcome $;
datalines;
21 1 O
21 2 N
53 1 O
53 2 O
53 3 Y
17 1 Y
17 2 Y
17 3 N
17 4 O
; 

PROC SORT data=have0 out=have1;
 by id_client n_try;
run;

data want;
 LENGTH pattern $ 50;
 set have1;
 retain pattern;
 by id_client;
 if first.id_client then pattern="";
 pattern=strip(pattern) !! ' ' !! strip(outcome);
run;

proc print; run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;BR,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 09:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-progressive-variable-by-another-variable/m-p/886774#M350395</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2023-07-28T09:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: create progressive variable by another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-progressive-variable-by-another-variable/m-p/886780#M350398</link>
      <description>&lt;P&gt;As this is your first post here, please understand that I give this advice to lots of people. Transforming data for distinct outcomes in each row, to something like ON when there are two outcomes, is often a mistake and actually makes further analysis more difficult. I would advise you to leave the data un-transformed, and &lt;FONT color="#FF0000"&gt;&lt;EM&gt;explain what you are going to do with it&lt;/EM&gt;&lt;/FONT&gt;, so we can determine good ways to perform the next steps and whether or not this transformation is helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 10:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-progressive-variable-by-another-variable/m-p/886780#M350398</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-28T10:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: create progressive variable by another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-progressive-variable-by-another-variable/m-p/886806#M350403</link>
      <description>&lt;P&gt;Thank you, it worked perfectly!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 13:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-progressive-variable-by-another-variable/m-p/886806#M350403</guid>
      <dc:creator>boshmers</dc:creator>
      <dc:date>2023-07-28T13:00:26Z</dc:date>
    </item>
  </channel>
</rss>

