home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 002 / document.arc / DBASEII.DOC < prev    next >
Encoding:
Text File  |  1984-03-10  |  14.3 KB  |  331 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                       NOTES ON USE OF CCDB FILES WITH DBASEIItm
  9.  
  10.  
  11.           These  remarks  are  designed for the dBaseII user with a general
  12.           familiarity with dBaseII but without experience in use  of  files
  13.           created  outside dBaseII.  Underlined words in the examples below
  14.           are as typed by a user.
  15.  
  16.           Data Base Set-up
  17.  
  18.           In order to work with a data  set,  dBaseII  must  first  convert
  19.           the  data  into  its  own  format.  Fortunately, this is a fairly
  20.           straightforward process.  The  user  should  be  aware,  however,
  21.           that  these  data  in  dBaseII  format  generally occupy 15 to 35
  22.           percent more space than in the comma-delimited format as provided
  23.           by  the  Bureau.   The  following  suggestions assume the user is
  24.           working with a machine with two 320 or 360 kb floppy disk drives.
  25.  
  26.           1.   If you plan to work with all of  a  file  which  is  120  to
  27.                160  kb  in  comma-delimited  format,  transfer the incoming
  28.                file onto the same disk as your dBaseII  system  using  COPY
  29.                or another systems utility prior to starting dBaseII.
  30.  
  31.           2.   "Create"  the  file  structure  for  dBaseII.  You will need
  32.                to enter in a name, type and field length  for  every  field
  33.                on  the  incoming file.  The following assumes you are using
  34.                the incoming file CCDB01.TXT as is.
  35.  
  36.                . CREATE
  37.                FILENAME:  B:COUNTY01                   (any name you select)
  38.                FIELD   NAME,TYPE,WIDTH,DECIMAL PLACES
  39.                001     GEOG8001,C,5
  40.                002     FLAG0011,N,1
  41.                003     LAND8001,N,7
  42.                004     FLAG0012,N,1
  43.                005     POPG7001,N,9
  44.                             .
  45.                             .
  46.                INPUT DATA NOW?  NO
  47.  
  48.                The name for each field can be  either  the  mnemonic  label
  49.                presented  in  the  data  dictionaries, or anything else you
  50.                choose within dBaseII naming  conventions  (e.g.  up  to  10
  51.                characters  long).   The  type  is  usually  N (numeric) for
  52.                flags and data  items,  and  usually  C  (character  string)
  53.                for  area  names  and  codes.   The width is the field size,
  54.                and errors will result if too few characters are  allocated.
  55.                The data dictionary shows the maximum digits required nationwide
  56.                for  each  item.  Decimal places need not be specified since
  57.                only integers are presented  on  the  files  (although  some
  58.                items have implied decimals).
  59.           _____________________
  60.           dBaseII is a trademark of Ashton-Tate
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.           2
  77.  
  78.                You  must  list  every field on the incoming file, including
  79.                flags.  If you want to extract only certain fields or  merge
  80.                fields  from  more  than one file, this may be done with the
  81.                UTILITYC program before  entering  dBaseII,  or  in  dBaseII
  82.                as  discussed  below  in  item  6.  (Note:  if you are using
  83.                an abbreviated  data  dictionary  created  by  the  UTILITYC
  84.                program,  don't  forget  that this format fails to list area
  85.                codes and flags even though they are still  present  in  the
  86.                data file.)
  87.  
  88.           3.   Load  the  incoming  data  into  the structure you have just
  89.                created.
  90.  
  91.                . USE B:COUNTY01
  92.                . APPEND FROM A:CCDB01.TXT DELIMITED
  93.  
  94.                If you want to enter in only certain kinds  of  records  you
  95.                may  make  that selection at this time.  For example, APPEND
  96.                FROM  A:CCDB01.TXT  FOR  $(GEOG8001,1,2)  =  "06"  DELIMITED
  97.                would  load  only data for California (state code 06).  This
  98.                kind of geographic extraction can also be done in the UTILITYC
  99.                program.  Extraction based on characteristics  can  be  done
  100.                only in dBaseII, e.g., APPEND FROM A:CCDB01.TXT FOR POPG8001
  101.                >= 50000 DELIMITED.
  102.  
  103.                A bug in dBaseII  is  that  occasionally  the  system  fails
  104.                to  capture the last few records when appending from a comma
  105.                delimited file.  If you find  that  the  number  of  records
  106.                is  slightly  less than it should be (e.g., 3189 in a county
  107.                file or 1008 in a city file), then you  will  need  to  take
  108.                the following actions:
  109.  
  110.                a.   Create  a  dummy  data  base with the same structure as
  111.                     the current data base using COPY  STRUCTURE  TO  DUMMY.
  112.                     Enter that file with USE DUMMY.
  113.  
  114.                b.   Create  several  dummy  records, for example, using the
  115.                     APPEND command and entering in zeroes  in  each  field.
  116.                     Enter COPY TO DUMMY.TXT DELIMITED.  
  117.  
  118.                c.   Add  the dummy records to your original comma delimited
  119.                     data file using the Copy command in DOS, after quitting
  120.                     dBaseII.  COPY filename.txt + DUMMY.TXT TO filename.txt.
  121.  
  122.                d.   Reenter  your  original  data  base in dBaseII and find
  123.                     out what was the last area  code  read  into  the  file
  124.                     earlier (e.g. GO BOTTOM then DISPLAY).
  125.  
  126.                e.   Append  the  remaining  records  from  the now-extended
  127.                     comma-delimited file  using  APPEND  FROM  filename.txt
  128.                     FOR  GEOG8001  >  "code", where "code" is the area code
  129.                     for the last record previously appended, e.g., "56041".
  130.             
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.                                                                           3
  145.  
  146.           4.   Link area names from a separate file.  As originally  issued
  147.                by  the  Bureau,  area names are on a separate file from any
  148.                of the data.  That file can be loaded  into  dBaseII  format
  149.                using  CREATE  and APPEND as discussed above.  The following
  150.                example assumes names have been loaded into COUNTY00.DBF.
  151.  
  152.                . USE B:COUNTY00
  153.                . SELECT SECONDARY
  154.                . USE B:COUNTY01
  155.                . SET LINKAGE ON
  156.  
  157.                The last command allows you to work with data for  the  same
  158.                area  in  both  files  when  you ask for any given record in
  159.                either file, assuming both files  feature  records  for  the
  160.                same  areas  in  the  same  order.  The first file is termed
  161.                the Primary file,  the  second  the  Secondary  file.   "P."
  162.                and  "S."  prefixes  are  used to tell dBaseII which file to
  163.                look in.  For example to list  by  name  all  counties  with
  164.                a population over 1,000,000, type DISPLAY P.GEOG8002, S.POPG8001
  165.                FOR  S.POPG8001  >= 1000000 .AND. $(S.GEOG8001,3,3) > "000".
  166.                (The last phrase, beginning with $, eliminates  state  total
  167.                records from the display.)
  168.  
  169.                Working  with  two  linked files at once can be tricky.  For
  170.                instance, if you have worked with either file before  typing
  171.                SET  LINKAGE  ON  you must first enter GO TOP for both files
  172.                to ensure  that  the  right  records  are  linked  together.
  173.                A  preferred  approach  would  be  to  extract and merge the
  174.                desired fields into  a  single  file  using  UTILITYC  prior
  175.                to  entering dBaseII, or in dBaseII using the UPDATE command
  176.                as described below in item 6.
  177.  
  178.           5.   Resorting or ranking records.  Sorted lists can be  prepared
  179.                using  either SORT or INDEX.  Indexing is usually preferred.
  180.                The following would  sort  all  counties  into  rank  order,
  181.                then  list  those  with  a  population over 500,000 in order
  182.                (identified only by code).
  183.  
  184.                . USE B:COUNTY01
  185.                . INDEX ON -POPG8001 TO B:POPRANK
  186.                . USE B:COUNTY01 INDEX B:POPRANK
  187.                . DISPLAY GEOG8001,POPG8001 FOR POPG8001 > 500000 .AND.
  188.                    $(GEOG8001,3,3) > "000" 
  189.  
  190.                Note that the indexing variable is presented as a  negative.
  191.                DBaseII  indexes  only  in  ascending  order,  so making the
  192.                value negative is necessary to get the  list  in  descending
  193.                order of population.  To display area names from a different
  194.                file, instead of codes, add the following commands:
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.           4
  213.  
  214.                . GO TOP
  215.                . SELECT SECONDARY
  216.                . USE B:COUNTY00 INDEX B:POPRANK
  217.                . DISPLAY S.GEOG8002,P.POPG8001 FOR POPG8001 > 500000 .AND.
  218.                    $(GEOG8001,3,3) > "000"
  219.  
  220.           6.   Merge data from multiple files.  When you want to  use  data
  221.                from  more  than  2  files  at  once, or when you are having
  222.                difficulty linking two files as described  in  items  4  and
  223.                5,  CREATE  a  new  data base with all of the desired fields
  224.                and UPDATE the data into it,  as  illustrated  below.   This
  225.                can  be  done  as  long as you have enough space on a single
  226.                device (diskette or hard disk)  to  accommodate  the  merged
  227.                file,  and  as  long  as you do not need to put more than 32
  228.                fields into a single file (a dBaseII limitation).
  229.  
  230.                . CREATE A COUMERGE
  231.                FIELD     NAME,TYPE,WIDTH,DECIMAL PLACES
  232.                001       GEOG8001,C,5        (geographic i.d. on all files)
  233.                002       GEOG8301,C,4
  234.                003       GEOG8302,C,2        (geographic fields from CCDB00.TXT
  235.                004       GEOG8303,C,4          now loaded into COUNTY00.DBF)
  236.                005       GEOG8101,C,4
  237.                006       GEOG8002,C,30
  238.                007       POPG7001,N,9        (selected data from CCDB01.TXT
  239.                008       POPG8001,N,9          now loaded into COUNTY01.DBF)
  240.                009       FLAG0244,N,1        (selected data from CCDB24.TXT
  241.                010       MONY7930,N,5          now loaded into COUNTY24.DBF)
  242.                011       _
  243.                INPUT DATA NOW?  N
  244.                . USE A:COUMERGE
  245.                . APPEND FROM B:COUNTY00
  246.                . GO TOP
  247.                . RESET
  248.                . UPDATE ON GEOG8001 FROM B:COUNTY01 REPLACE POPG7001,POPG8001
  249.                . GO TOP
  250.                . RESET
  251.                . UPDATE ON GEOG8001 FROM B:COUNTY24 REPLACE FLAG0244,MONY7930
  252.  
  253.                In creating merged files of  especially  selected  items  it
  254.                is  tempting  to  drop  all flag fields.  In some cases this
  255.                is quite appropriate.  Some items, e.g.,  total  population,
  256.                have  no  flags other than zero.  In some applications, e.g.
  257.                ranking areas, there is no way  to  make  use  of  the  flag
  258.                and  the  flag  can  be  dropped.   This can be accomplished
  259.                by copying the data to  another  file  using  a  field  list
  260.                which omits unwanted flags.
  261.  
  262.                On  the  other  hand,  in  routine data display, some flags,
  263.                such as 4 for suppression for disclosure reasons, are important
  264.                to show.  One alternative is to  replace  the  zero  in  the
  265.                data  field  with  the negative of the flag value (e.g., -4)
  266.                and drop the flag.  In subsequent  displays  it  would  then
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.                                                                           5
  281.  
  282.                be necessary to screen fields for negative values and display
  283.                a  message  instead  of  a  data  value.  This approach must
  284.                be avoided wherever real negative values  may  occur  (e.g.,
  285.                farm  earnings)  or  where  you will want to use the data in
  286.                calculations without prior screening.
  287.  
  288.           7.   Pack data where necessary.  In some cases it may seem important
  289.                to have on one file more  than  32  data  fields.   One  way
  290.                around  this  dBaseII  limitation  is to store several items
  291.                within a single character string.  For example, if  in  step
  292.                2 above we had added at the end of the record a 50-character
  293.                type-C field named MERGEPOP we could pack all  the  original
  294.                data  items  and  their  flags  into that field, which could
  295.                later be moved to a consolidated data file.  For example,
  296.  
  297.                . USE B:COUNTY01
  298.                . REPLACE ALL MERGEPOP WITH STR(FLAG0011,1) + STR(LAND8001,7)
  299.                    + STR(FLAG0012,1) + STR(POPG7001,9) + ...
  300.  
  301.                Any subsequent reference  would  then  require  use  of  the
  302.                substring  function.   For  example, to reconstruct POPG7001
  303.                use VAL($(MERGEPOP,10,9)), i.e., the value of the  substring
  304.                within  MERGEPOP  beginning  with  the  10th character and 9
  305.                characters in length.
  306.  
  307.                Consolidation of merged files into a single data base  would
  308.                require  creating  a  separate data base with fields defined
  309.                to accept the merged character strings.
  310.  
  311.                . CREATE A COUMERGE
  312.                FIELD     NAME,TYPE,WIDTH,DECIMAL PLACES
  313.                001       GEOG8001,C,5
  314.                002       MERGEPOP,C,50
  315.                003       MERGEAGE,C,45
  316.                004       _
  317.                INPUT DATA NOW?  N
  318.                . USE A:COUMERGE
  319.                . APPEND FROM B:COUNTY01
  320.                . GO TOP
  321.                . RESET
  322.                . UPDATE ON GEOG8001 FROM B:COUNTY04 REPLACE MERGEAGE
  323.  
  324.                Packing data this way into long character strings is extravagant
  325.                of disk space, and impractical to use if the  original  file
  326.                occupies  a  large  part  of available disk space.  The only
  327.                purpose it serves is to circumvent  the  dBaseII  limitation
  328.                to 32 fields.
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.