The following SAS program is submitted: data work.new; length word $7; amount = 7; if amount = 5 then word = 'CAT'; else if amount = 7 then word = 'DOG'; else word = 'NONE!!!'; amount = 5; run; Which one of the following represents the values of the AMOUNT and WORD variables?
Explanation: always "Dog" will be assigned to word as amount is hardcoded 7 in the begining of each iteration and a value of 5 is saved in amount as it is hardcoded before the end of each output.
This question checks your knowledge about how sas reads. When SAS reads in the iterations in sequence, it first writes 5 to the variable 'amount'in PDV. Then it reads through the condition and writes 'DOG' for variable 'word' in PDV. Then it again encounters the value 7 and writes to 'Amount' in PDV. As this is not a loop and run statement follows, SAS gives the output from PDV which would be 5 and 'Dog'
Question :
When the following SAS program is submitted, the data set SASDATA.PRDSALES contains 5000 observations: libname sasdata 'SAS-data-library'; options obs = 500; proc print data = sasdata.prdsales (firstobs = 100); run; options obs = max; proc means data = sasdata.prdsales (firstobs = 500); run; How many observations are processed by each procedure?
Explanation: OBS option will let SAS know last observation to process. FIRSTOBS option will let SAS know first observation to process. So for first proc print FIRSTOBS =100 and OBS (i like to call it LASTOBS) = 500, so there are 401 observation (including 100th observation) processed by it. Now for proc means FIRSTOBS=500 and OBS (or LASTOBS) = Max (or 5000 in this case), so there are 4501 observation (including 500th observation) is processed by it.
An easy way to figure out how many observations are between a first observation at 100 (firstobs=100) and a last observation (obs=500) at 500 is to simplify it first.
Let's say I want to know how many observations are between my first observation (firstobs=1) at 1, and my last observation (obs=5) at 5. There are: 1.. 2.. 3.. 4.. 5. If I'm subtracting (5-1=4), I'm not counting that last observation. And you know, even just by counting your fingers, there are 5 observations between 1 and 5. So it's really (5-1+1=5). This is the same thing with firstobs=100 and obs=500. (500-100+1=401).
Question :
In the following SAS program, the input data files are sorted by the NAMES variable: libname temp 'SAS-data-library'; data temp.sales; merge temp.sales work.receipt; by names; run; Which one of the following results occurs when this program is submitted?
1. The program executes successfully and a temporary SAS data set is created. 2. The program executes successfully and a permanent SAS data set is created. 3. Access Mostly Uused Products by 50000+ Subscribers 4. The program fails execution because the SAS data sets on the MERGE statement are in two different libraries.
Explanation: Both datasets sales and receipt are sorted by names variable which in turn is used to merge the two datasets. The resulting dataset is over-written on temp.sales dataset. As temp is a permanent library unlike work (which is temparory) option B is the right choice
1)temp is declared as a permanent lib so permanent dataset will be craeted 2)same dataset can be read and write in a step 3)work and perm datasets can be merged