Can anyone tell me to how to save time while declaring variables in a var statement.
However, I am familiar with ques1-ques100 etc. but I have different variable names.
Please help me.
Thanks
Hi, Camp might this image would help you,
Besides this you can use following:
If you want to select all variables then you can leave your var statement (then there should be no class etc. statements in the procedure that you are using where you have to declare some variables)
Var1 -numeric- Var2 for all numeric variables between Var1 and var2.
Var1 -char- var2 for all char variables between var1 and var2.
VAR_: all variables that begins with Name VAR (colon with var_ is necessary).
Also you can use dataset options like: drop= (to drop some variables) & Keep= (to keep selected variables).
Again Besides these you can either use:
1. Drag and Drop of variables from dataset (present in your liabrary) or,
2. You can run query of required dataset and copy the variables that you want (but remember to remove comma(s)).
For these two, see the following video:
http://support.sas.com/training/tutorial/studio/index.html
See the first video.
It depends on your needs.
You can, for example, ignore the var statement in which case sas considers all numeric variables.
proc means data=sashelp.class;
class age;
run;
Or you can interrogate the dictionary tables (if you know how to identify the variables) and write the result of the query within a macro variable which you later use in the var statement.
Use a normalised data strucuture, this reduces the amount of "vars" and will make coding far easier:
So instead of:
ID QUEST1 DOB AGE VAR1 VAR2 VAR3 IDE OPT ERT...
1 ABCD 21mar12 3 XYZ DEf 34 5 R 3
Something like:
ID QUESTION CHARACTER_RESPONSE NUMERIC_RESPONSE
1 QUEST1 ABCD .
1 DOB 21mar12 21mar12
1 AGE 3 3
2 VAR1 XYZ .
...
The topic you are asking about is usually referred to as "variable lists". Here are a few more examples that apply to a VAR statement:
_numeric_ = all numeric variables
_character_ = all character variables
abc: = all variable names that begin with the characters "abc"
cat -- dog = all variables from cat through dog (in the order that they were created)
cat -numeric- dog = all numeric variables from cat through dog (in the order that they were created)
cat -character- dog = all character variables from cat through dog (in the order that they were created)
Thanks
Hi, Camp might this image would help you,
Besides this you can use following:
If you want to select all variables then you can leave your var statement (then there should be no class etc. statements in the procedure that you are using where you have to declare some variables)
Var1 -numeric- Var2 for all numeric variables between Var1 and var2.
Var1 -char- var2 for all char variables between var1 and var2.
VAR_: all variables that begins with Name VAR (colon with var_ is necessary).
Also you can use dataset options like: drop= (to drop some variables) & Keep= (to keep selected variables).
Again Besides these you can either use:
1. Drag and Drop of variables from dataset (present in your liabrary) or,
2. You can run query of required dataset and copy the variables that you want (but remember to remove comma(s)).
For these two, see the following video:
http://support.sas.com/training/tutorial/studio/index.html
See the first video.
Thanks for your solution and video links
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.