01-25-2018
Aad
Calcite | Level 5
Member since
01-16-2013
- 8 Posts
- 0 Likes Given
- 0 Solutions
- 6 Likes Received
-
Latest posts by Aad
Subject Views Posted 1119 06-10-2014 02:11 AM 1533 11-22-2013 09:10 AM 2155 05-17-2013 04:55 AM 2163 05-17-2013 04:09 AM 1031 04-26-2013 02:52 AM 3294 01-18-2013 07:44 AM -
Activity Feed for Aad
- Got a Like for Re: Collecting multiple record in to one observation. 09-01-2015 04:24 AM
- Got a Like for Re: Avoid WARNING from the code without changing variables name or Code Structure. 09-01-2015 04:24 AM
- Posted Re: Avoid WARNING from the code without changing variables name or Code Structure on SAS Programming. 06-10-2014 02:11 AM
- Posted Re: The extended penalty problem... on SAS Procedures. 11-22-2013 09:10 AM
- Posted Re: Collecting multiple record in to one observation on SAS Procedures. 05-17-2013 04:55 AM
- Posted Re: Collecting multiple record in to one observation on SAS Procedures. 05-17-2013 04:09 AM
- Posted Re: How to manage this type of file? Please Help. Many Thanks on SAS Programming. 04-26-2013 02:52 AM
- Posted Re: Translate SQL to SAS on SAS Programming. 01-18-2013 07:44 AM
-
My Liked Posts
Subject Likes Posted 3 05-17-2013 04:09 AM 3 06-10-2014 02:11 AM
06-10-2014
02:11 AM
3 Likes
If you just run this program with one additional statement, you see what code is generated by the macro. Add this statement ahead of the first line in your program and you see exactly what happens: OPTIONS MPRINT;
... View more
11-22-2013
09:10 AM
The excellent explanation of your problem challenged me to write a 9-statement solution plus comments as follows. Hope you enjoy it ... Data Mistakes; /*-----------------------------------------------------------------*/ /* Generate simulation table with dates and some random Mistakes */ /*-----------------------------------------------------------------*/ Attrib Date Length = 4 Format = Date11. Mistake Length = 2 Format = 1.; Do Date = '01-jan-2013'd to '31-dec-2013'd; Mistake = Round (RanUni (5), 1); Output; End; Run; /*1*/Data Mistakes; /*-----------------------------------------------------------------*/ /* Re-generate table, including PENALTIES_TO_GO and PENALTY values */ /*-----------------------------------------------------------------*/ /*2*/ Attrib Date Length = 4 Format = Date9. Mistake Length = 3 Format = 1. Penalty Length = 3 Format = 1. Penalties_to_go Length = 3 Format = 8. /*3*/ Set Mistakes; /*-----------------------------------------------------------------*/ /* PENALTY becomes 1 if current and last 3 dates all had MISTAKE=1 */ /*-----------------------------------------------------------------*/ /*4*/ Penalty = Mistake * Lag1 (Mistake) * Lag2 (Mistake) * Lag3 (Mistake); /*-----------------------------------------------------------------*/ /* Accumulate the number of PENALTIES_TO_GO */ /*-----------------------------------------------------------------*/ /*5*/ Penalties_to_go + Penalty; /*-----------------------------------------------------------------*/ /* If current+last 3 days had MISTAKE=1, and 4 days ago MISTAKE=0, */ /* then increase the PENALTIES_TO_GO by an additional 3 penalties. */ /*-----------------------------------------------------------------*/ /*6*/ If Penalty > Lag4 (Mistake) >= 0 Then Penalties_to_go + 3; /*-----------------------------------------------------------------*/ /* Assign a PENALTY if current date has MISTAKE=0 and there are */ /* still one or more PENALTIES_TO_GO. */ /*-----------------------------------------------------------------*/ /*7*/ Penalty = (Error = 0 and Penalties_to_go > 0); /*-----------------------------------------------------------------*/ /* Decrease the number of PENALTIES_TO_GO only if PENALTY=1 */ /*-----------------------------------------------------------------*/ /*8*/ Penalties_to_go + -Penalty; /*9*/ Run; Proc Print Uniform; Run;
... View more
05-17-2013
04:55 AM
U're right; the initial problem description however didn't mention any "multiple date report", hence my - often overlooked - suggestion to use INPUT @ 'textstring'.
... View more
05-17-2013
04:09 AM
3 Likes
Hi, this program will do the job for you. Apart from the declarations, only the last statement is executed for each input line, and that single statement will do the job for jou. No PRXPARSEs, no checks for missing or empty lines or whatsoever. The power of the 'INPUT @ 'text string' is terribly powerful yet almost unknown ... Eventually, following changes may be required: -1- It your date is not in the DD-MM-YY format, replace the first ATTRIB line accordingly -2- Fill the proper reference to your input in the INFILE statement below DATA AnyName; ATTRIB Date Format = ddmmyyd8. InFormat = ddmmyy. Time Format = time5. InFormat = time. Trm Format = $8. User Format = 8. Cmd Format = $2. Table Format = $5. Meter Format = 12.2 Inventory Format = 12.2 Patron Format = 4.; RETAIN Date; INFILE TextFile; IF _N_=1 THEN INPUT @ 'TRANSACTION FILE LISTING FOR' Date @ 'DETAILS'; INPUT Time Trm User Cmd / Table Meter Inventory Patron; RUN;
... View more
04-26-2013
02:52 AM
A variation on the above solution which does not use IF statements anymore: Data WANT (Drop = TEMP); Set YOUR_DATA; Retain TEMP; TEMP = Coalesce (ACCNT_NUM, TEMP); ACCNT_NUM = TEMP; RUN; NOTE: If the ACCNT_NUM, though the name sugests otherwise, is a CHARACTER variable, you should replace the Coalesce woth a CoalesceC
... View more
01-18-2013
07:44 AM
Better alternative is to use PROC SUMMARY as it does NOT calculate statistics at all, unless requested to do so. And of course, omitting calculation saves time (eventually you loose your coffee break ) Proc Summary NoPrint Nway Missing; By Max_N Cr_Scor Bad_Dept_at_Conn Dep_Unpaid Chg_Off; Output Out = Whichever_Name_You_Want (Drop = _type_); Run; This writes exactly 1 row for each combination of BY-variables. BTW: You may need a PROC SORT before you call PROC SUMMARY if the data is not in proper order, or you may replace the BY statement with an identical CLASS statement. It depends on your input wether the SORT+BY or the CLASS version is most efficient.
... View more