LoginSignup
0
0

More than 3 years have passed since last update.

CASTableをメソッドとパラメータとで条件指定する

Posted at

SAS ViyaはAIプラットフォームです。PythonやJava、Rなどの言語を通して利用できます。そのSAS Viyaの中で使われているのがCASTableというテーブルオブジェクトです(CASはCloud Analytic Servicesの略です)。CASTableでは条件指定にメソッドとパラメータが使えます。今回はその方法を紹介します。

CASTableを取得する

以下のようにしてCASTableを取得します。

iris = conn.CASTable('data.iris', caslib='casuser')

メソッドによる指定

メソッドでは set_param を使います。一つ目の引数に条件名、次に値を指定します。

iris.set_param('where', 'sepal_length > 6.8 and species = "virginica"')
iris.set_param('computedvars', ['length_factor'])
iris.set_param('computedvarsprogram', 'length_factor = sepal_length * petal_length;')

条件はまとめて与えることもできます。

iris.set_params('where', 'sepal_length > 6.8 and species = "virginica"',
                'computedvars', ['length_factor'],
                'computedvarsprogram', 'length_factor = sepal_length * petal_length;')

要素による指定

同様に要素で指定します。

iris.params.where = 'sepal_length > 6.8 and species = "virginica"'
iris.params.computedvars = ['length_factor']
iris.params.computedvarsprogram = 'length_factor = sepal_length * petal_length;'

どちらも同じ意味になります。

まとめ

set_paramは複数の条件をまとめて指定できるのが魅力です。プログラムとして順番に指定していくならば、要素で指定する方が分かりやすいかも知れません。使いやすい方で指定してみてください。

SAS Viya | SAS

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0