I want to test if a variable exists and if it doesn't, create it.
相关问题
- Delete the group that none of its observation cont
- Reading data from a SAS data source in .Net
- Simple way to do a weighted hot deck imputation in
- Problems with SAS DDE with Office 2010
- Reading observations from SAS dataset into arrays
相关文章
- Finding all possible paths in a dataset using sas
- How do I save a TextEdit (mac) file with a custom
- Logical function in SAS to determine if a particul
- Efficiently concatenate many sas datasets
- How to test property existence and type based on N
- How to check whether a tuple exists in a Python li
- Python sas7bdat module usage
- Any point in using LIMIT in EXISTS query?
Assign
var4
to itself. The assignment will create the variable if it doesn't exist and leave the contents in place if it does.Just remember that creating
var4
this way when it doesn't exist will use the default variable attributes, so you may need to use an explicitattrib
statement if you require specific formatting/length etc.This is a very late answer/comment, but this method works for me and is pretty simple (SAS 9.4). In the below example, I used missing numeric and character variables and assigned a value to the missing character variable is missing.
The
open()
&varnum()
functions can be used. Non-zero output fromvarnum()
indicates the variable exists.(assuming var4 is numeric)