I can't readily think of a way to have a formula accomplish a COUNT DISTINCT. However, you can get the value via a couple Table Summaries and a Table Join, which you can then code into JSL if you choose.
In Table A, Select Table --> Summary, Group By subjectid, select OK. In the summary table, select Table --> Summary, Select subjectid, and select "N" under Statistics, select OK. In the new table, delete the "N Rows" Column. Go back to the first table, and select Table --> Join. Then select to join with the last summary table with matching specification of Cartesian Join, then select OK. The distinct count will show up in your original table.
If you were to script it:
dt = Current Data Table();
sumdt = dt << Summary( Group( :subjectid ), invisible );
sumsumdt = sumdt << Summary( Group, N( :subjectid ), invisible );
count_distinctdt = dt << Join(
With( sumsumdt ),
Cartesian Join
);
count_distinctdt << delete columns("N Rows");
column("N(subjectid)") << set name("count distinct subjectid");
sumsumdt << close window;
sumdt << close window;
close(dt,no save);