First you make a mistake in copying the code your first type is in that case: type ='0';
if not go to third!
you have a first datastep creating a sas dataset with the name type
written in the library defined behind the libref ca
In that data step, you are reading temporary sas dataset cak and adding to every
observations a new variable numeric type with value 0
with a second datastep you are taking the preceeding table issued from the datastep
and adding once again cak dataset.
as the structure is the same for both dataset except that you don't have the type variable
in cak, type will take as value the . as missing value
in the third step you are sorting the final ca.type dataset upon the value of type
Third Now a personnal remark :
If you are saying that type as already values like 1 2 3
I too don't understand nothing
so my final suggestion
work step by step
and after every step take a look at your output table with VT command
to understand what's happening to type!
And read your log especially after the first step submit.