13.07.2015 Views

Download pdf guide - VSN International

Download pdf guide - VSN International

Download pdf guide - VSN International

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

58 5 Calculations and manipulationcan do this for only one vector at a time.Alternatively, you can first apply a restriction to the required subset, using sub-optionsof the Restrict/Filter option of the Spread menu on the menu bar, and then clicking on theRestricted rows sub-option of the Delete option of the Spread menu. This deletes theunwanted rows, and then uses READ to read the subset into GenStat. You can form thesubset for several vectors at once. However, the subset replaces their original values.5.4 PracticalUsing the data on sales of personal computers in Practical 5.2, print the names of themonths when fewer than 10 were sold. Calculate the total amount received in just thosemonths. Do you get the same answer by using RESTRICT and SUBSET?5.5 Sorting dataThe SORT directive allows you to reorder the units of a list of vectors according to oneor more index vectors. The first parameter (OLDVECTOR) specifies the vectors whosevalues are to be sorted, and NEWVECTOR supplies structures to store the sorted values.First we sort the names and monthly pay values from the example in Section 5.1 intoalphabetic order of names.63 " Sort alphabetically."64 SORT [INDEX=name] monthpay,name; NEWVECTOR=sortpay,sortname65 PRINT sortname,sortpay; DECIMALS=0,2sortname sortpayAdams 1875.00BakerClarke1435.001382.50Day 856.25Edwards 1095.00Foster 1740.00Grey 1187.50Hill *Innes 1281.25Jones 1218.75The index vectors can be texts (as above), factors, or variates. They can be specifiedusing the INDEX option, as above, but if this is omitted, GenStat uses the first old vector.We now sort the names and monthly pay into descending order of the amount paid. Bydefault, values are sorted into ascending order, but this can be changed by setting optionDIRECTION to descending as shown below.66 " Sort into descending order of monthly pay."67 SORT [DIRECTION=descending] monthpay,name; NEWVECTOR=sortpay,sortname68 PRINT sortname,sortpay; DECIMALS=0,2sortname sortpayHill *Adams 1875.00Foster 1740.00Baker 1435.00Clarke 1382.50Innes 1281.25Jones 1218.75Grey 1187.50Edwards 1095.00Day 856.25

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!