Hello everyone,
I have an SAS question in terms of the "index" when doing "rename", as follows:
The SAS data set WORK.TEST has an index on the variable ID and the following
SAS program is submitted.
data WORK.TEST;
set WORK.TEST(
keep=ID Var_1 Var_2
rename=(ID=ID_Code);
Total=sum(Var_1 Var_2);
run;
Which describes the result of submitting the SAS program?
A.
The index on ID is deleted.
B.
The index on ID is updated as an index on ID_Code.
C.
The index on ID is deleted and an index on ID_Code is created.
D.
The index on ID is recreated as an index on ID_Code. The answer seems A, and I wonder why. Any help would be appreciated.
I chose C.
Indeed. - Actually, if you run the code as given above, the dataset test will not be replaced because of syntax errors. The code is missing a comma and a closing parenthesis.
The datastep creates a new dataset for which no index is defined.
Thank you very much!
so the new data set (the new WORK.TEST) has no index?
Thank you!
Indeed. - Actually, if you run the code as given above, the dataset test will not be replaced because of syntax errors. The code is missing a comma and a closing parenthesis.
Yes, the answer is A.
If you want to preserve the index, use the Copy Statement in PROC DATASETS with Index=YES (Default).
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.