Skip to content
The Chat Archive
llama-4-scout-17b-16e-instruct· Meta LMArena Human Preference 140K

sas znajdź numer rekordu w tabeli dla spełnionego warunku col1='test'

  1. User

    sas znajdź numer rekordu w tabeli dla spełnionego warunku col1='test'

  2. Assistant

    Oto przykładowy kod w SAS, który znajduje numer rekordu w tabeli dla spełnionego warunku col1='test':

    data test;
      col1 = 'test';
      col2 = 10;
    run;
    
    data test;
      col1 = 'other';
      col2 = 20;
    run;
    
    data test;
      col1 = 'test';
      col2 = 30;
    run;
    
    proc sql;
      select _N_ 
      from test 
      where col1 = 'test';
    quit;
    

    Jednak powyższy kod zwróci numery wierszy tylko dla tych wierszy, które spełniają warunek col1='test'. Jeśli chcesz mieć numer rekordu oryginalnej tabeli, możesz użyć _N_ w DATA step:

    data test;
      col1 = 'test';
      col2 = 10;
      output;
      col1 = 'other';
      col2 = 20;
      output;
      col1 = 'test';
      col2 = 30;
      output;
    run;
    
    data wynik;
      set test;
      if col1 = 'test' then numer_rekordu = _N_;
    run;
    
    proc print data=wynik;
    run;
    

    Lub alternatywnie możesz użyć proc sql z monotonic():

    proc sql;
      select monotonic() as numer_rekordu, col1, col2
      from test
      where col1 = 'test';
    quit;
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.