Command Reference : Function Reference : Function Reference: C
  
 
@convert
Converts series, alpha, or group to matrix objects after removing NAs.
Syntax: @convert(o[, s])
o: series, alpha, group
s: (optional) sample string or object
Return: vector, svector, matrix
Convert data in the series (numeric or alpha) or group object into a vector (numeric or alpha) or group after removing rows with an NA or “”.
If o is a series, @convert returns a vector from the values of o using the optional sample s or the current workfile sample. If any observation has the value “NA”, the observation will be omitted from the vector.
If o is an alpha series, @convert returns an svector from the values of o using the optional sample s or the current workfile sample.
If o is a group, @convert returns a matrix from the values of o using the optional sample object smp or the current workfile sample.
The data for series in o are placed in the columns of the resulting matrix in the order they appear in the group spreadsheet. If any of the series for a given observation has the value “NA”, the observation will be omitted for all series.
Note that if the group contains alpha series, they are treated as numeric series with all NA values for purposes of this conversion.
For a conversion method that preserves NAs, see stomna.
Examples
vector v2 = @convert(ser1)
vector v3 = @convert(ser2, "2000m12 2022m01")
converts the numeric series SER1 and SER2 into the vectors V2 and V3. V2 contains all non-missing elements in the current workfile sample, while V3 contains non-missing elements from 2000m12 to 2022m01.
sample smpl "2000m10 2022m05"
svector a2 = @convert(alp1)
svector a3 = @convert(alp2, smpl)
converts the alpha series ALP1 and ALP2 into the svectors A2 and A3. A2 contains all non-missing (non-blank) elements in the current workfile sample, while A3 contains non-missing elements from 2000m10 to 2022m05.
matrix m1 = @convert(grp1)
matrix m2 = @convert(grp1, smpl)
converts the series in the group GRP1 into the matrices M1 and M2.
M1 uses all non-missing observations in the current workfile sample, while M2 uses non-missing observations in the sample object from 2000m10 to 2022m05. Note that if GRP1 contains alpha series, they are treated as numeric series with all NA values for purposes of this conversion.
Cross-references
See also mtos, stom, stomna, and ttom.