The following SAS program is submitted:
data work.test;
set work.staff (keep = jansales febsales marsales);
array diff_sales{3} difsales1 - difsales3;
array monthly{3} jansales febsales marsales;
run;
Which one of the following represents the new variables that are created?
A. JANSALES, FEBSALES and MARSALES
B. MONTHLY1, MONTHLY2 and MONTHLY3
C. DIFSALES1, DIFSALES2 and DIFSALES3
D. DIFF_SALES1, DIFF_SALES2 and DIFF_SALES3
Click Comment link to get answer
'C'
ReplyDeleteC is the correct answer
ReplyDeleteAn sis C becoz other 3 var are not new but coming from data set being read as its option say in keep..
Deletehope it helps
some one can please expalain to me, I am not clear about Array
ReplyDeletesynatx:array array_name(len_ofarray) var_list;
ReplyDeletevar_list could be new or existing vars in datasets.
in the above program, dif_sales1- dif_sales3 are new.
bcos,jansales,febsales,marsales are existing in work.staff dataset.
diff_sales is the array name.
ans is c
ReplyDeletearray diff_sales{3} difsales1 - difsales3;
ReplyDeleteThis above statement creates three new variables diff_sales1, diff_sales2, and diff_sales3 because they don't already exist in the WORK.STAFF dataset.
so are two Anonymous people saying that the answer is D?
ReplyDeletei think it's C.
On the book it says
ARRAY array-name(dimensino)
"if no elements are listed, new variables will be created with DEFAULT NAME"
On here, what is "DEFAULT NAMEs refering to?
Thx in advance.
Default name refers to diff_sales1 diff_sales2 diff_sales3 respectively as opposed to the user defined difsales1 - difsales3 which yields difsales1 difsales2 difsales3.
ReplyDeleted
ReplyDeletewhy is it not the option B? can anyone explain the second array statement?
ReplyDeleteThe answer is C.. the reason is if you look at the set statement : 'set work.staff (keep = jansales febsales marsales);' jansales, febsales, marsales are variables you are bringing in. The array: array diff_sales{3} difsales1 - difsales3;are the variables you want to create - since there is no other programming code to define the variables, SAS creates the variables the array defines. Since these arrays are numeric, the variables created are also numeric.
ReplyDeleteThank you for explaining
DeleteCheers!
General form ARRAY statement:
ReplyDeleteARRAY array_name{dimension};
If no elements are listed , new var.s will be created with default names.The default var. names are created by concatenating the array name and the numbers 1,2,3 and so on, upto the array dimension.If you prefer, you can specify individual var names. To specify var. names , you list each name as an element of the array.
so the answer is c.