Document 11049228

advertisement
Sample Problem & Solutions......................................................................................................................................... 1
Simple Request from one file using ‘count’ and ‘where’ in SIS......................................................................... 1
ANSWER Request from one file using ‘count’ and ‘where’ in SIS................................................................... 1
Simple Focexec Requests in ADS ............................................................................................................................ 2
Exercise 1 ................................................................................................................................................................. 2
Exercise 2 ................................................................................................................................................................. 2
Exercise 3 ................................................................................................................................................................. 2
Exercise 4 ................................................................................................................................................................. 2
Exercise 5 ................................................................................................................................................................. 3
Simple Focexec Requests ADS – Answer Key...................................................................................................... 3
IN-GROUPS-OF.............................................................................................................................................................. 4
COLUMN and ROW TOTAL....................................................................................................................................... 4
MASKING........................................................................................................................................................................ 5
ANYTHING MORE SOPHISTICTED AND WE MUST USE A JOIN .............................................................. 5
FROM THE Marist College FOCUS Manual............................................................................................................. 6
DEFINE TO CREATE NEW FIELDS ....................................................................................................................... 6
DEFINE YOUR FILES TO GET WHAT YOU WANT.......................................................................................... 6
Sample Problem & Solutions
Simple Request from one file using ‘count’ and ‘where’ in SIS
Problem: Write a file that gets me a count of all the Environmental Science and Biology
majors for the years 98 – 02. Sort the output by major.
Here is the frame for such a focexec – we fill in the fields we need to pull
-* ENSC AND BIOL MAJORS FOR
-* 1998 99 00 01 02
TABLE FILE RTFILE
COUNT ____
-*COUNT THE NUMBER OF STUDENT IDS
BY _____
-*SORTED BY THE MAJOR
WHERE ____ EQ '____' OR '____'
-*WHERE THE MAJOR IS EITHER ENVIRONMENTAL SCIENCE OR BIOLOGY
WHERE RT005 EQ '____$' OR '____$$' OR '____$'
-*AND FOR THE YEARS 1998, 99, 00, 01, 02
END
ANSWER Request from one file using ‘count’ and ‘where’ in SIS
-* ENSC AND BIOL MAJORS FOR
-* 1998 99 00 01 02
TABLE FILE RTFILE
COUNT RT010
-*COUNT THE NUMBER OF STUDENT IDS
BY RT120
-*SORTED BY THE MAJOR
WHERE RT120 EQ 'ENSC' OR 'BIOL'
-*WHERE THE MAJOR IS EITHER ENVIRONMENTAL SCIENCE OR BIOLOGY
WHERE RT005 EQ '1998$' OR '200$$' OR '1999$'
-*AND FOR THE YEARS 1998, 99, 00, 01, 02
END
Simple Focexec Requests in ADS
Exercise 1
1.
2.
3.
4.
5.
6.
Write a simple Focexec. In the following Focex you will use a “where” statement. You will
use the LPfile to print the Cid for alumni in a particular reunion year.
Create a focexec entitled AlYEAR. (The Al represents the alumni office)
Use the Lpfile for this focexec. The fields that you will use are CID_LP and REUN_YR_1.
Print CID_LP by REUN_YR_1.
Where REUN_YR_1 eq ‘1997’ (when using a where statement, it is always followed by a
semicolon ; )
Limit your records – If recordlimit eq 100
Exercise 2
1.Write a simple Focexec. In the following Focexec you will use a“where” statement. You will
use the LPfile to print the CID for alumni in a particular reunion year range.
2. Create a focexec entitled AlYEAR1. (The Al represents the alumni office)
3. Use the Lpfile for this focexec. The fields that you will use are CID_LP and REUN_YR_1.
4. Print CID_LP by REUN_YR_1
5. If the reunion year is greater to or equal to 1997. (use GE instead of EQ)
6. Limit your records – If recordlimit eq ‘100’
Exercise 3
1.
2.
3.
4.
Exercise 4
Create a new Focexec entitled ALIF1
Print Constituent ID numbers and occupation type for those who occupation has
been recorded as Business-Entrepreneur/Owner. (Screen 8 on ADS) Limit your
records to 100.
If preferred constituent type equals alumni
Construct your focexec.
1.
2.
3.
Alter Focexec ALIF1
Print Constituent ID numbers and occupation type for those who occupation has
been recorded as Medicine/Health, Nursing and Dentistry. (Screen 8 on ADS) Limit
your records to 100.
If preferred constituent type equals alumni
Exercise 5
1.
2.
3.
4.
Write a simple focus using count. Create a new focexec called ALSTATE.
Using the LCFILE count cid (column -total), for alum, with active status, and good
addresses.
Include the line “WHERE NON_DEG_ALUM EQ ‘N’;” by home state as state.
Include a heading that will describe what this report is and the date.
Simple Focexec Requests ADS – Answer Key
Exercise 1
TABLE FILE LPFILE
PRINT CID_LP
BY REUN_YR_1
WHERE REUN_YR_1 EQ ‘1997’;
IF RECORDLIMIT EQ ‘100’
END
Exercise 2
TABLE FILE LPFILE
PRINT CID_LP
BY REUN_YR_1
WHERE REUN_YR_1 GE ‘1997’
IF RECORDLIMIT EQ ‘100’
END
Exercise 3
TABLE FILE LCFILE
PRINT CID_LC OCC_TYP_LC
IF OCC_TYPE_LC EQ ‘BE’
IF PREF_CONST EQ ‘ALUM’
IF RECORDLIMIT EQ ‘100’
END
Exercise 4
TABLE FILE LCFILE
PRINT CID_LC OCC_TYP_LC
IF OCC_TYP_LC EQ ‘ME’ OR ‘NU’
IF PREF_CONST EQ ‘ALUM’
IF RECORDLIMIT EQ ‘100’
END
Exercise 5
TABLE FILE LCFILE
COUNT CID_LC AS ‘TOTAL’ COLUMN-TOTAL
WHERE PREF_CONST EQ ‘ALUM’;
WHERE ACTV_STAT_LC EQ ‘A’
WHERE HM_ADDR_STAT EQ ‘ ’
WHERE NON_DEG_ALUM EQ ‘N’
BY HM_STATE AS ‘STATE’
HEADING
“ALUMNI BY STATE”
“ACTIVE STATUS, GOOD ADDRESSES”
“AS OF &DATE </1”
Note: </1 indicates that the user would like a blank line in between the heading and the rest of the
report. If you would like two lines it would be
</2.
IN-GROUPS-OF
TABLE FILE RTFILE
COUNT RT010 BY RT040
IN-GROUPS-OF 500 TOP 4
END
COLUMN and ROW TOTAL
TABLE FILE RTFILE
SUM RT020 AND RT025
AND COLUMN-TOTAL
BY RT120 BY RT105
END
TABLE FILE RTFILE
SUM RT025 ACROSS RT105
AND ROW-TOTAL
END
TABLE FILE RTFILE
SUM RT162 AND ROW-TOTAL AND COLUMN-TOTAL
ACROSS RT105
BY RT120
END
TABLE FILE RTFILE
SUM RT162 AND RT036
BY RT105
BY RT120
ON TABLE COLUMN-TOTAL
END
MASKING
TABLE FILE SGFILE
PRINT SGV04 BY SGV10
BY SGV05
IF SGV05 GE ‘T’
-*OR WE COULD USE A MASK AND SPECIFY THAT REST OF CHARS BE IGNORED IF WE *DID NOT WANT EVERY NAME THAT HAD A T IN IT
-*IF SGV05 EQ ‘T$’
-*SO ONLY THOSE NAMES BEGINNING WITH T – IGNORE OTHER CHARS
END
TABLE FILE RTFILE
PRINT RT010 AND RT040
BY PCT_INC
BY RT120
IF RT005 EQ ‘2003S’ OR ‘2002F’
IF RT040 FROM 2.5 TO 4
END
TABLE FILE ADFILE
PRINT AD002 AND AD255 AND AD265
IF AD265 CONTAINS ‘845’ OR ‘518’ OR ‘212’
-*IF AD26B EQ ‘ ‘ - WHAT IF RESTRICTED THIS?
END
~~~~~~~~~~~~
ANYTHING MORE SOPHISTICTED AND WE MUST USE A JOIN
TABLE FILE RTFILE
PRINT RT010
IF RT120 EQ ‘ENGL’
IF RT005 EQ ‘2003S’
ON TABLE HOLD AS ENGLISH
END
JOIN RT010 IN ENGLISH TO AA002 IN AAFILE AS JOIN1
TABLE FILE ENGLISH
PRINT AA002 AA008 AA003
BY AA011
ON TABLE HOLD AS ENGNAMED
END
JOIN AA002 IN ENGNAMED TO AD002 IN ADFILE AS JOIN2
TABLE FILE ENGNAMED
PRINT AA008 AA003
OVER AD240
OVER AD250 AD255 AD260
BY AA003 SKIP-LINE
END
FROM THE Marist College FOCUS Manual
TABLE FILE RTFILE
PRINT RT14C RT205
BY RT010
WHERE (RT005 EQ ‘2002S’) AND (RT020 GE 12) AND (RT14E EQ ‘U’);
ON TABLE HOLD AS STUDS
END
JOIN RT010 IN STUDS TO KEY IN AAFILE AS J1
TABLE FILE STUDS
PRINT AA002 AA003 RT14C
BY RT205
END
~~~~~~~~~~~~~~~~~~~~
DEFINE TO CREATE NEW FIELDS
THE DEFINE COMMAND IS AND INSTRUCTION TO FOCUS TO PERFORM CERTAIN
FUNCTIONS THAT ARE NOT READILY AVAILABLE OTHERWISE WITH THE FIELDS IN
THE MFD
SYNTAX:
DEFINE FILE filename NEW FIELD/format = EXPRESSION;
END
DEFINE FILE RTFILE
-*BELOW PLACES AN A FOR WINTER, B FOR SPRING, C FOR SUMMER, D FOR FALL
SORTSEM/A5 = IF EDIT(RT005,'$$$$9') EQ 'W' THEN
EDIT (RT005,'9999$')|| 'A' ELSE
IF EDIT (RT005,'$$$$9') EQ 'S' THEN
EDIT (RT005,'9999$')|| 'B' ELSE
IF EDIT (RT005,'$$$$9') EQ 'U' THEN
EDIT (RT005,'9999$')|| 'C' ELSE
EDIT (RT005,'9999$')|| 'D';
END
DEFINE FILE RTFILE
TERM /A05 = EDIT (RT005, IF ‘$$$$F’ THEN ‘$$$$A’ ELSE IF ‘$$$$W’ THEN ‘$$$$B’ ELSE IF
‘$$$$S’ THEN ‘$$$$C’ ELSE IF ‘$$$$U’ THEN ‘$$$$D’);
END
THAT WAY WE CAN ORDER THE TERMS ACCORDING TO OUR ACADEMIC CALENDAR –
OTHERWISE IT WOULD PRINT FALL, SPRING, SUMMER, THEN WINTER
DEFINE YOUR FILES TO GET WHAT YOU WANT
DEFINE FILE RTFILE
LEVEL/A03 = EDIT (RT14C, IF ‘FR’ THEN ‘A1’ ELSE IF ‘SO’ THEN ‘B1’ ELSE IF ‘JR’ THEN
‘C1’ ELSE IF ‘SR’ THEN ‘D1’)
END
WITHOUT THIS DEFINE WE’D HAVE THE CLASS LEVELS PRINTING OUT FR, JR, SO, SR
- INSTEAD OF THE CONSECUTIVE PROGRESSION OF FRESHMEN SOPHOMORE JUNIOR
THEN SENIOR
DEFINE FILE RTFILE
CLSS/A12=DECODE RT14C(‘FR’ ‘A-FRESHMAN’ ‘SO’ ‘B-SOPHOMORE’ ‘JR’ ‘C-JUNIOR’
‘SR’ ‘D-SENIOR’);
END
TABLE FILE RTFILE
PRINT RT010
BY RT120
BY CLSS
IF RT005 EQ &SEM
END
WHAT IF WE WANTED THE DASHES IN THE SSN?
DEFINE FILE RTFILE
SSN/A11=EDIT(RT010, ‘999-99-9999’);
END
OR DEFINE FILE AAFILE
STUID/A11=EDIT (AA002,’999-99-9999’);
END
DATE CONVERT
BDAY/A8= EDIT (AA010, '$$$$99$$')|'/'|
EDIT (AA010, '$$$$$$99')|'/'|
EDIT (AA010, '$$99$$$$');
END
SOMETIMES YOU HAVE TO JOIN TWO TABLES THAT DO NOT SHARE A COMMON
PRIMARY KEY – SO YOU FORCE THE JOIN AND SUPPORT IT WITH A DEFINE
JOIN TEMP 1 WITH RT305 IN RTFILE TO RC005 IN RCFILE AS JOINRTRC
Now we need to define this new field:
DEFINE FILE RTFILE
TEMP1/A16= RT005 | RT305
END
Important:
You must issue the DEFINE after the JOIN but before the TABLE request.
Here is our Focexec up to this point:
JOIN TEMP1 with RT305 in RTFILE to KEY in RCFILE as JOINRTRC
DEFINE FILE RTFILE
TEMP1/A14= RT005 | RT305
END
WHAT IS THAT VERTICAL BAR? CONCATENATION
DEFINE FILE AAFILE
NAME/A47= AA053|AA003
END
CONCATENATE NICKNAME WITH NAME – ADDED 15 TO 32 FOR NEW FIELD LENGTH
WHAT IF WE WANTED TO USE THE SUBROUTINE PROVIDED TO US BY IT CALLED
‘ADDRESS1’
WE USE A ‘DASH INCLUDE’
-INCLUDE ADDRESS1
BUT WE CAN ONLY USE THIS ONCE WE HAVE PULLED OUR SAMPLE POPULATION AND
DEFINED A FIELD THAT WILL GIVE US THE KEY TO MATCH ON
To print addresses on a report, you have to use what’s called a subroutine. This mini program looks at all
the addresses a student has and provides you with the one you specify. The s ubroutine provides you with
new “fields” you will use to print addresses. They are referred to as the AP elements because they all begin
with AP.
Including the AP elements in your Focexec
There are three components you need to include in your Focexec to use the AP elements:
1.-SET &ADDRPREF = ‘xxx’;
2.a DEFINEd field entitled SSN/A09 = social security number (explained below)
3.-INCLUDE ADDRESS1
-SET
The -SET command tells Focus to assign a value for ADDRPREF. ADDRPREF is your way of telling
Focus which address to include in your report. The PREF in the variable ADDRPREF says, what is your
first preference for an address, if I can’t find that one is there an alternative I can provide you with? For
example, you would like to print addresses for full-time undergraduates. You would like their dorm address
if they are a resident, their commuter address for an on-campus PO Box, or a permanent address if they do
not have either of the previous ones. You would write:
-SET &ADDRPREF = ‘MP’;
Your -SET command can be at the very top of the Focexec or you can include it after your last JOIN.
DEFINEd SSN
You must define a field called SSN. Focus needs the institution and the ID number of the student to pull the
correct address from the AAFILE for you. For most SIS users, you begin your Focexec by selecting records
from the RTFILE. You do this with the intention of joining this smaller subset of data to either the RA or
the AAFILE or both. In this case you have already used institution and id to join—RT010. You can use
RT010 in your define:
DEFINE FILE HOLDFILE
FORMKEY/A09 = RT010;
-INCLUDE ADDRESS1
END
RUN
TABLE FILE HOLDFILE
PRINT AP130 AP200_F
AP205_F AP210_F
AP215_F AP230_U
AP235_U AP240_U
BY AP240_U
END
OR WE COULD USE THE FORMATTING TECHNIQUE OVER
HOWEVER IF WE PULL THIS DOWN AS TEXT AND IMPORT INTO EXCEL TO DO A
MAILMERGE WE NEED THE DATA LAIN OUT LEFT TO RIGHT
BATCH TO HELD OUTPUT
NEXT SEND DATA TO SELF AS A TEXT FILE
IMPORT TO EXCEL
MAIL MERGE - LABELS
CAN DO INSTITUTIONAL LABELS AS WELL
LARGE NUMBER? BATCH AS A NONPRINT TO CREATE LABELS
DEFINE VERSUS COMPUTE
TABLE FILE RTFILE
PRINT RT020
BY RT010IF RT005 EQ &SEM
ON TABLE HOLD AS CURRCRED
END
JOIN RT010 IN CURRCRED TO KEY IN RAFILE AS J1
TABLE FILE CURRCRED
PRINT RT020 AS ‘Curr,Credits’ RA320
COMPUTE NEWTOT/I6=RT020 + RA320;
BY RA005
IF RA305 EQ ‘U’
END
TABLE FILE RTFILE
PRINT RT040 RT005
BY RT010
IF RT020 GE 12
IF RT005 EQ &SEM
ON TABLE HOLD AS SEMGPAS
END
DEFINE FILE SEMGPAS
DEANSLST/A3 = IF RT040 GT 2.5 THEN ‘YES’ ELSE ‘NO’;
END
TABLE FILE SEMGPAS
SUM RT040 NOPRINT
COMPUTE YEARGPA/D5.2 = RT040/2; AND
COMPUTE DEAN2/A3 = IF (RT040/2) GT 2.5 THEN ‘YES’ ELSE ‘NO’;
BY RT010
PRINT RT040 DEANSLST
BY SUBKEY_RT
PRINT RT040 DEANSLST
BY RT010
END
Example of matching
DEFINE FILE RCFILE
DAY1/A7 = DECODE RC240('M' '1MON' 'MW' '1MON' 'T' '2TUES' 'TR' '2TUES'
'TF' '2TUES' 'W' '3WED' 'R' '4THU'
'F' '5FRI' 'MR' '1MON' 'MWR' '1MON');
DAY2/A7 = DECODE RC240('MW' '3WED' 'TR' '4THU' 'TF' '5FRI'
'MR' '4THU' 'MWR' '3WED');
DAY3/A7 = DECODE RC240('MWR' '4THU');
END
TABLE FILE RCFILE
PRINT RC240 RC245 RC250 RC255 RC260
BY RC010
BY ROOT_KEY
IF RC240 EQ DAY1
IF RC005 EQ &SEM
WHERE RC090 NE 'X'
ON TABLE HOLD AS COURSE1
END
TABLE FILE RCFILE
PRINT RC240 RC245 RC250 RC255 RC260
BY RC010
BY ROOT_KEY
IF RC240 EQ DAY2
IF RC005 EQ &SEM
WHERE RC090 NE 'X'
ON TABLE HOLD AS COURSE2
END
TABLE FILE RCFILE
PRINT RC240 RC245 RC250 RC255 RC260
BY RC010
BY ROOT_KEY
IF RC240 EQ DAY2
IF RC005 EQ &SEM
WHERE RC090 NE 'X'
ON TABLE HOLD AS COURSE3
END
JOIN RC010 IN COURSE3 TO RC010 IN COURSE2 AS J1
JOIN RC010 IN COURSE1 TO RC010 IN COURSE3 AS J3
END
MATCH FILE COURSE1
PRINT RC240 RC245 RC250 RC255 RC260
BY RC010 NOPRINT
RUN
FILE COURSE2
PRINT RC240 RC245 RC250 RC255 RC260
BY RC010 NOPRINT
AFTER MATCH HOLD AS COURSES OLD-AND-NEW
END
TABLE FILE COURSES
PRINT RC245 AS 'STARTING,FROM,THIS,TIME' RC250 AS 'CLASS,END,TIME'
BY DAY1
BY DAY2
BY DAY3
BY RC255 AS 'BUILDING' IN 10
BY RC260 AS 'ROOM' IN 20
-*IF RC005 EQ '&SEM'
-*IF RC093 EQ '20'
-*IF RECORDLIMIT EQ 100
END
Download