<?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: BY Variables not sorted properly in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/BY-Variables-not-sorted-properly/m-p/825403#M326038</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404650"&gt;@MILKYLOVE&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add the appropriate ORDER BY clause to the PROC SQL step creating&amp;nbsp;&lt;FONT face="courier new,courier"&gt;work.t2a_extract_email&lt;/FONT&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;order by SOURCE, NU_ODS_PER_ROLE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as you did in your first PROC SQL step. Or, shorter and similar to your second&amp;nbsp;PROC SQL step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;order by 1, 2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 26 Jul 2022 08:52:55 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2022-07-26T08:52:55Z</dc:date>
    <item>
      <title>BY Variables not sorted properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Variables-not-sorted-properly/m-p/825401#M326036</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do the below extraction where I have a file named t_extract_fichier_5a at the end.&lt;/P&gt;&lt;P&gt;However I am getting errors at the last step where I am creating the file&amp;nbsp;t_extract_fichier_5a.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error I am getting is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino"&gt;&lt;EM&gt;&lt;STRONG&gt;ERROR:&lt;/STRONG&gt; &lt;FONT face="helvetica"&gt;BY variables are not properly sorted on data set work.t2a_extract_email&lt;/FONT&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="helvetica"&gt;&lt;EM&gt;SOURCE=DWHC NU_ODS_PER_ROLE=2342008 x=Email EMAIL=&amp;amp;LT;ASSISTANTE@ALSACEMICRO.FR&amp;amp;GT; WK_Blacklist=. FIRST.SOURCE=1 LAST.SOURCE=1&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="helvetica"&gt;&lt;EM&gt;FIRST.NU_ODS_PER_ROLE=1 LAST.NU_ODS_PER_ROLE=1 _ERROR_=1 _N_=2&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="helvetica"&gt;My code:&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;*** paths not included ***&lt;BR /&gt;&lt;BR /&gt;proc sql;
          create table personne_email as
                select distinct SOURCE
                     , NU_ODS_PER_ROLE
                     , EMAIL
                     , NU_TEL_MOB_HPERP
                from client.personne 
                     where TOP_CLT_ACTIF = 1
                          and CD_TYP_PP_PM_HPER = 'M' 
                          and TOP_CLT_DCD = 0
                     order by SOURCE, NU_ODS_PER_ROLE;
     quit;

     proc import datafile= "&amp;amp;chemin_bdc./bdc_coordonnees_invalides.xlsx"
          out=bdc_coord_inval
          dbms=xlsx replace;
          sheet="Coordonnées KO";
     run;

     proc sql;
          create table bdc_coord_inval_email as 
                select upcase(VALEUR2) as EMAIL, 0 as WK_Blacklist
                     from bdc_coord_inval
                          where CD_TYP eq "EMAIL" and SOURCE_DEPOT eq "BKL"
                               order by 1;
     quit;

     proc sort data=work.personne_email nodupkey;
          by EMAIL;
     run;

     proc sort data= work.bdc_coord_inval_email nodupkey;
          by EMAIL;
     run;


     proc sql;
          create table work.t2a_extract_email as
                select  a.SOURCE , a.NU_ODS_PER_ROLE, a.EMAIL, b.wk_blacklist
                     from work.personne_email as a
                          left join  work.bdc_coord_inval_email  as b
                               on a.EMAIL = b.EMAIL;
     quit;

     Data t_extract_fichier5a;
          retain SOURCE NU_ODS_PER_ROLE x EMAIL WK_Blacklist;
          set t2a_extract_email (keep= SOURCE NU_ODS_PER_ROLE EMAIL WK_Blacklist);
          x = "Email";
          by SOURCE NU_ODS_PER_ROLE ;
          run;&lt;/PRE&gt;&lt;P&gt;&lt;FONT face="helvetica"&gt;I can't seem to understand where the issue is coming. Please help.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="georgia,palatino"&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/FONT&gt;&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, 26 Jul 2022 08:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Variables-not-sorted-properly/m-p/825401#M326036</guid>
      <dc:creator>MILKYLOVE</dc:creator>
      <dc:date>2022-07-26T08:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: BY Variables not sorted properly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Variables-not-sorted-properly/m-p/825403#M326038</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404650"&gt;@MILKYLOVE&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add the appropriate ORDER BY clause to the PROC SQL step creating&amp;nbsp;&lt;FONT face="courier new,courier"&gt;work.t2a_extract_email&lt;/FONT&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;order by SOURCE, NU_ODS_PER_ROLE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as you did in your first PROC SQL step. Or, shorter and similar to your second&amp;nbsp;PROC SQL step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;order by 1, 2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jul 2022 08:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Variables-not-sorted-properly/m-p/825403#M326038</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-07-26T08:52:55Z</dc:date>
    </item>
  </channel>
</rss>

