BookmarkSubscribeRSS Feed
Tecla1
Quartz | Level 8

Good afternoon, 

 

there is a best way to do this better (a very big program...) and in a few time ?:

 

Many tnks !!!!


data base_new_e_1911; 
set Anadefi.Base_dati_90_e_1911;
if OUT_VOCE_CD= 'ALRTN1' and OUT_RISPOSTA_CD=2 then do;
ALRTN1_2=1;
ALRTN1_3=0;
ALRTN1_5=0;
ALRTN1_6=0;
ALRTN1_98=0;
ALRTN1_99=0;
ALRTN2_0=0;
ALRTN2_10=0;
ALRTN2_3=0;
ALRTN2_6=0;
ALRTN2_99=0;
ALRTN3_0=0;
ALRTN3_2=0;
ALRTN3_3=0;
ALRTN3_99=0;
ALRTN4_2=0;
ALRTN4_3=0;
ALRTN4_99=0;
ALRTN5_0=0;
ALRTN5_2=0;
ALRTN5_3=0;
ALRTN5_4=0;
ALRTN5_7=0;
ALRTN5_8=0;
ALRTN5_99=0;
ALRTN6_0=0;
ALRTN6_2=0;
ALRTN6_3=0;
ALRTN6_4=0;
ALRTN6_99=0;
ALRTN7_0=0;
ALRTN7_1=0;
ALRTN7_2=0;
ALRTN7_3=0;
ALRTN7_7=0;
ALRTN7_99=0;
ALRTN8_0=0;
ALRTN8_1=0;
ALRTN8_3=0;
ALRTN8_99=0;
ALRTN9_0=0;
ALRTN9_5=0;
ALRTN9_7=0;
ALRTN9_99=0;
CNTGL_0=0;
CNTGL_1=0;
CNTGL_2=0;
CNTGL_3=0;
CNTGL_4=0;
CNTGL_5=0;
C_B10_0=0;
C_B10_15=0;
C_B13_0=0;
C_B13_5=0;
C_B2_0=0;
C_B2_10=0;
C_B2_30=0;
C_B3_0=0;
C_B3_20=0;
C_B4_0=0;
C_B4_10=0;
C_B4_15=0;
C_B4_5=0;
C_B5_0=0;
C_B5_10=0;
C_B5_15=0;
C_B5_5=0;
C_B6_0=0;
C_B6_20=0;
C_B7_5=0;
C_B7_0=0;
C_B8P_0=0;
C_B8P_10=0;
C_B9_0=0;
C_B9_15=0;
C_B9_5=0;
C_B9B_0=0;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;
NTCB1_0=0;
NTCB1_1=0;
NTCB2_0=0;
NTCB2_1=0;
NTCB3_0=0;
NTCB3_1=0;
NTCB4_0=0;
NTCB4_1=0;
NTFAT_0=0;
NTFAT_1=0;
NTFAT_10=0;
NTFAT_2=0;
NTFAT_3=0;
NTFAT_4=0;
NTFAT_5=0;
PDNOR_10=0;
PDNOR_11=0;
PDNOR_12=0;
PDNOR_13=0;
PDNOR_14=0;
PDNOR_15=0;
PDNOR_2=0;
PDNOR_3=0;
PDNOR_4=0;
PDNOR_5=0;
PDNOR_6=0;
PDNOR_7=0;
PDNOR_8=0;
PDNOR_9=0;
PDNOR_99=0;
SFNOT_0=0;
SFNOT_1=0;
SFNOT_10=0;
SFNOT_11=0;
SFNOT_12=0;
SFNOT_14=0;
SFNOT_2=0;
SFNOT_3=0;
SFNOT_4=0;
SFNOT_5=0;
SFNOT_6=0;
SFNOT_7=0;
SFNOT_8=0;
SFNOT_9=0;
SRP_0=0;
SRP_2=0;
SRP_3=0;
SRP_4=0;

end;
if OUT_VOCE_CD= 'ALRTN1' and OUT_RISPOSTA_CD=3 then do;
ALRTN1_2=0;
ALRTN1_3=1;
ALRTN1_5=0;

2 REPLIES 2
Astounding
PROC Star

Ask if you need help with this idea:

 

  1. Put all the variables into an array
  2. Set all the array elements to zero
  3. Use IF/THEN statements to change variable(s) from 0 to 1.

It should be much shorter and much less prone to error.

Reeza
Super User

Here's a tutorial on using Arrays in SAS
https://stats.idre.ucla.edu/sas/seminars/sas-arrays/

 

What's the rule for setting those specific variables to 0?

Are those new variables or do they already exist in the data set?

 


@Tecla1 wrote:

Good afternoon, 

 

there is a best way to do this better (a very big program...) and in a few time ?:

 

Many tnks !!!!


data base_new_e_1911; 
set Anadefi.Base_dati_90_e_1911;
if OUT_VOCE_CD= 'ALRTN1' and OUT_RISPOSTA_CD=2 then do;
ALRTN1_2=1;
ALRTN1_3=0;
ALRTN1_5=0;
ALRTN1_6=0;
ALRTN1_98=0;
ALRTN1_99=0;
ALRT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DNOR_2=0;
PDNOR_3=0;
PDNOR_4=0;
PDNOR_5=0;
PDNOR_6=0;
PDNOR_7=0;
PDNOR_8=0;
PDNOR_9=0;
PDNOR_99=0;
SFNOT_0=0;
SFNOT_1=0;
SFNOT_10=0;
SFNOT_11=0;
SFNOT_12=0;
SFNOT_14=0;
SFNOT_2=0;
SFNOT_3=0;
SFNOT_4=0;
SFNOT_5=0;
SFNOT_6=0;
SFNOT_7=0;
SFNOT_8=0;
SFNOT_9=0;
SRP_0=0;
SRP_2=0;
SRP_3=0;
SRP_4=0;

end;
if OUT_VOCE_CD= 'ALRTN1' and OUT_RISPOSTA_CD=3 then do;
ALRTN1_2=0;
ALRTN1_3=1;
ALRTN1_5=0;


 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 353 views
  • 0 likes
  • 3 in conversation