Question

I have the data in a sav file

CODE  |  QUANTITY
------|----------
A     |  1
B     |  4
C     |  1
F     |  3
B     |  3
D     |  12
D     |  5

I need to obtain the quantity of codes which have a quantity <= 3 and to obtain the proportion in a percentage with respect to the total number and present a result like this

<= 3  |  PERCENTAGE
------|----------
4     |  57 %

All of this using SPSS syntax.

Was it helpful?

Solution 2

I dont know how you migrate your question here, I dont have reputation here to add screen shoots that's help you allot. Anyhow the procedure of your desire output is given below.

Goto Transform->Count Values within cases a dialogue box open, write the name of new variable say "New" in Target Variable: go to define values a new dialogue box is open then check the radio button Range, LOWEST through value: put in below box 3 and then press add and press continue and press ok. A new variable is created with the name of "New". Now go to Analyze -> Descriptive Statistics-> Frequencies, new dialogue box will be open send "New" variable into Variable(s): press Statistics in new dialogue box check Percentile(s): write 100 in box and press Add and then continue and ok. You get the desire results.

OTHER TIPS

I would first convert the quantity value to a 0-1 variable, and then aggregate by code to the mean. This produces a nice second dataset to make a table. Example below.

data list free / Code (A1) Quantity (F2.0).
begin data
A 1
B 4
C 1
F 3
B 3
D 12
D 5
end data.

*convert to 0-1.
compute QuantityB3 = (Quantity LE 3).

*Aggregate.
DATASET DECLARE AggQuant.
AGGREGATE
  /OUTFILE='AggQuant'
  /BREAK=Code
  /QuantityB3 = MEAN(QuantityB3).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top