Please reply again and this time include a "pasted SAS log" record of what problem / error messages you are getting. It appears you are using SAS macro variable(s), so you will want to include as much information about your program execution as possible, by including this command in your SAS script to add as much diagnostic output to the SAS log, revealing your program flow as possible:
OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MPRINT;
Also, sharing information about your SAS environment will help as well, such as has your program ever run successfully (is it new or existing?), what OS platform are you running SAS on, is SAS installed local or on a "connected" server, maching, and also SAS version info.
Also, I believe you have some challenges using the SAS SET statement and those dataset options when you are attempting to compute the first-observations to start and the observation-count to execute.
Timing problem. FIRSTOBS and OBS options are evaluated at data step compile time so in your code the value of numeroRandom is not yet known. Try it like this:
%let numeroosservazioni=19 ; /* I used this for my test */
data _null_ ;
numeroRandom = round(rand('unifor')*(&numeroOsservazioni+1));
if numeroRandom = &numeroOsservazioni+1 then do;
numeroRandom = &numeroOsservazioni;
call symput('_nr',put(numeroRandom,best.)) ;
%put NumeroOsservazioni <&numeroosservazioni> ;
%put _nr <&_nr> ;
set sashelp.class /* I used this for my test */
(firstobs = &_nr
obs = &_nr