data w; length acctno $13 deactreason $4 dealertype $2 Province $2; infile datalines dsd delimiter = '|'; informat actdt mmddyy10. deactdt mmddyy10. sales dollar8.0; input acctno $ actdt deactdt deactreason $ goodcredit rateplan dealertype $ AGE Province $ sales; datalines; 1176913194483|06/20/1999|||0|1|A1|58|BC|128 1176914599423|10/04/1999|10/15/1999|NEED|1|1|A1|45|AB|72 1176951913656|07/01/2000|||0|1|A1|57|BC|593 1176954000288|05/30/2000|||1|2|A1|47|ON|83 1176969186303|12/13/2000|||1|1|C1|82|BC| 1176991056273|08/31/1999|09/18/2000|MOVE|1|1|C1|92|QC|1041 1176991866552|05/24/2000|||1|1|A1|77|ON| 1176992889500|11/28/2000|||1|1|C1|68|AB|72 1177000067271|12/23/1999|||0|1|B1|75|ON|134 1177010940613|12/09/1999|||1|2|A1|42|NS|11 1177025997013|11/09/1999|||1|1|A1|26|BC|154 1177027515760|10/19/1999|||1|1|B1|73|BC|16 1177028996676|09/21/2000|||0|1|C1||QC|179 1177038747105|03/14/2000|||0|1|C1|41|ON|705 1177045857516|06/22/2000|||1|1|A1|53|QC|83 1177057406016|09/21/2000|||0|1|C1|50|ON|529 1177066422248|04/26/1999|01/15/2001|NEED|0|1|A2|55|NS|44 ; run; I need to find the following: The number of activated and deactivated accounts? My codes don’t produced the desired results; please pinpoint where need fixing proc sort data=w out=w2 (keep=actdt deactdt); by acctno ; run; data w; set wireless (keep= actdt deactdt); by acctno; *** sets the first new value to null ***; if first.actdt then count=.; Here I’m missing the code for the deactdt count *** starts counting by 1 by actdt ***; count+1; new_var=_n_; run; Or data w2; set w (keep= actdt deactdt); by acctno; *** holds the value of count and sets the default value ***; retain count 0; *** adds the value of count per each new value of actdt & deactdt ***; if first.actdt then count=count+1; Again I’m missing the code to for the deactdt count run; Are there any missing activated and deactivated dates? /* create a format to group missing and nonmissing */ proc format; value $missfmt ' '='Missing' other='Not Missing'; value missfmt . ='Missing' other='Not Missing'; run; Or proc freq data=wireless; format _CHAR_ $missfmt.; /* apply format for the duration of this PROC */ tables _CHAR_ / missing missprint nocum nopercent; format _NUMERIC_ missfmt.; tables _NUMERIC_ / missing missprint nocum nopercent; run; Since I have a lot of variables, make sense to count the missing values using an ARRAY and the CMISS function, is this right? What if I want count a select variable set, such as actdt and deactdt? data countmissing; set w; array vars(10) acctno $ actdt deactdt deactreason $ goodcredit rateplan dealertype $ AGE Province $ sales _NUMERIC_; missing=0; do i = 1 to 10; if vars(i)=' ' then missing+1; end; /* Using CMISS, only one statement needed rather than 5: */ c_miss_missing = cmiss(of vars[*]); drop i; run; proc print; run; Or proc iml; use Missing; read all var _NUM_ into x; close Missing; rowMiss = countmiss(x, "ROW"); /* returns 0,1,2 or 3 for each row */ print rowmiss; When is the earliest and latest activation and deactivation dates available? proc sql; create table w2 as select min(thedates) as min_date format=mmddyy10., max(thedates) as max_date format=mmddyy10. from w; quit; proc print; title from dataset &syslast;run; proc transpose data=w2 out=new(rename=(_name_=date)) ; run; proc print; title from dataset &syslast;run; What is the age and province distributions of active and deactivated customers? (Use dashboards)
... View more