<?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: Opimisation SAS code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/871025#M344046</link>
    <description>&lt;P&gt;Hope this will help you-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc freq data=have;
tables id_appel*demand_label / list nocol norow out=work.tmp(drop=percent) ;
run;

proc sort data=tmp1; by demand_label; run;

data tmp1;
length demand_label $1.;
set tmp;
run;

proc transpose data=tmp1 out=tmp2;
by id_appel;
id demand_label;
var count;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2023 06:28:21 GMT</pubDate>
    <dc:creator>vijaypratap0195</dc:creator>
    <dc:date>2023-04-21T06:28:21Z</dc:date>
    <item>
      <title>Opimisation SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/870824#M343981</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;my have and want tables are as following&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id_appel id_demande $ demand_label $20. ;
cards;
1 A-01 Appointement
1 C-09 Contract
2 A-08 Appointement
2 D-10 Devis
2 C-11 Contract
2 C-29 Contract
;
run;
data want;
input id_appel nb_dmd_A nb_dmd_B nb_dmd_C nb_dmd_D ;
cards ;
1 1 0 1 0
2 1 0 2 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This code is work for me&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data= have;
by id_appel demand_label;
quit;

data want;
set have;
by id_appel;

if first.id_appel then do;
nb_dmd_A=0;
nb_dmd_B=0;
nb_dmd_C=0;
nb_dmd_D=0;
end;

retain nb_dmd_: 0;

if demand_label="Appointement" then nb_dmd_A = nb_dmd_A+1;
if demand_label="BBB" then nb_dmd_B = nb_dmd_B+ 1; 
if demand_label="Contract" then nb_dmd_C = nb_dmd_C+1;
if demand_label="Devis" then nb_dmd_D= nb_dmd_D+ 1; 

if last.id_appel;
drop id_demande demand_label;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I am looking to optimise my codes because i have many demand_label different .&lt;/P&gt;
&lt;P&gt;Can my codes be optimized ? Can you help me please?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any suggestion i am open for more details ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks. Regards!!!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 15:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/870824#M343981</guid>
      <dc:creator>kelxxx</dc:creator>
      <dc:date>2023-04-20T15:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: Opimisation SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/870834#M343988</link>
      <description>&lt;P&gt;Take a look at &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p0f0fjpjeuco4gn1ri963f683mi4.htm" target="_self"&gt;PROC MEANS&lt;/A&gt; and &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p0aq3hsvflztfzn1xa2wt6s35oy6.htm" target="_self"&gt;PROC SUMMARY&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=have n ;
	class id_appel demand_label ;
	var id_appel ;
run ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Apr 2023 16:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/870834#M343988</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2023-04-20T16:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Opimisation SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/870840#M343991</link>
      <description>&lt;P&gt;Is there any reason you need to use DEMAND_LABEL in your program?&amp;nbsp; Can't you just use the first character in ID_DEMANDE instead?&amp;nbsp; This might get you most of the way there:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
   tables id_appel * id_demande / noprint out=counts (keep=id_appel id_demande count);&lt;BR /&gt;   format id_demande $1.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You still need to reformat the counts (including adding zeros where appropriate ... see if the SPARSE option would do that for you), but wouldn't those counts be correct?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 16:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/870840#M343991</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-04-20T16:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Opimisation SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/870843#M343993</link>
      <description>&lt;P&gt;Dynamic code is preferable IMO even if slightly longer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use the PRELOADFMT and PROC FREQ to generate all combinations for results&lt;/LI&gt;
&lt;LI&gt;PROC TABULATE has the displayed results if that's all you need.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Transpose data from PROC TABULATE into data set, if desired.&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I'll leave the renaming of columns up to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id_appel id_demande $ demand_label $20. ;
cards;
1 A-01 Appointement
1 C-09 Contract
2 A-08 Appointement
2 D-10 Devis
2 C-11 Contract
2 C-29 Contract
;
run;


proc sort data= have;
by id_appel id_demande;
quit;

proc format;
value $ demande_list 
'A' = 'A'
'B' = 'B'
'C' = 'C'
'D' = 'D';
run;

proc tabulate data=have out=long;
class id_appel;
class id_demande / preloadfmt;
format id_demande $demande_list1.;
table id_appel, id_demande*N='' / printmiss misstext='0';
run;

data long;
set long;
if missing(N) then N=0;
run;

proc transpose data=long out=want;
by id_appel;
id id_demande;
var N;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Apr 2023 16:36:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/870843#M343993</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-04-20T16:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Opimisation SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/870851#M343997</link>
      <description>Like the use of PRELOADFMT option.</description>
      <pubDate>Thu, 20 Apr 2023 17:51:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/870851#M343997</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-04-20T17:51:49Z</dc:date>
    </item>
    <item>
      <title>Re: Opimisation SAS code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/871025#M344046</link>
      <description>&lt;P&gt;Hope this will help you-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc freq data=have;
tables id_appel*demand_label / list nocol norow out=work.tmp(drop=percent) ;
run;

proc sort data=tmp1; by demand_label; run;

data tmp1;
length demand_label $1.;
set tmp;
run;

proc transpose data=tmp1 out=tmp2;
by id_appel;
id demand_label;
var count;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 06:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Opimisation-SAS-code/m-p/871025#M344046</guid>
      <dc:creator>vijaypratap0195</dc:creator>
      <dc:date>2023-04-21T06:28:21Z</dc:date>
    </item>
  </channel>
</rss>

