- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have Table1 in the format
Var1 Var2 Var3 Var4 Var5 ... ... Var103
A E I M Q U
B F J R V
C K O
D H L P T X
Where Variables Var3 through Var103 are alpha-numeric in alphabetical order, But their alphabetic prefixes are different. So i cannot reference them as Var3-Var103 to create an array.
I also have Table2
Col1 Col2
Var3 1
Var4 2
Var5 3
....
....
Var103 100
Is it possible to switch Var3 to Var103 in Table1 with the 1-100 from Table2, so as to be able to reference them as an array.
Then once I finish manipulating the array as needed, switch back to Var3 to Var103?
Or simpler, is there a way to fill the missing values in Table1 with '.' values, without referencing each variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The Array would be Var4-Var103
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Where Variables Var3 through Var103 are alpha-numeric in alphabetical order, But their alphabetic prefixes are different. So i cannot reference them as Var3-Var103 to create an array.
Does this mean that the variables are not really named Var3 to Var103, but might be something like pig4, duck5, goose6, gorilla7, giraffe8, ..., monkey103?
If so, to create an array, you could use
array x pig4--monkey103;
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would suggest that changing a variable name may be a tad confusing if you don't use the data set for awhile or share the data with others (especially ).
If you only have a few gaps in your integer sequence you could use something like
arrray v var1-var27 var29-var99 var103;
Most places a variable "list" can be used can accept gaps.
If the variables are contiguous (next to each other in the data set or have sequential variable order numbers in Proc Contents output) then the double dash @PaigeMiller suggests is appropriate as well as working for non-common names for all.
And if there are no other variables that start with the same name you can use the colon list generator. var: would a list of all variables whose names start with var.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@mcook wrote:
No, they do not have sequential numbers in proc contents. How might i go about achieving that?
Show us your proc contents variables list information and indicate which variables you need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@mcook wrote:
No, they do not have sequential numbers in proc contents. How might i go about achieving that?
As long as the variables are sequential in your SAS data set, the numbers in the variable names are not meaningful. The double-dash variable list works in the case of sequential variables.
Paige Miller