How to pick every third row in SAS

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 21

  • @9356079
    @9356079 3 роки тому

    Nicely explained👍

  • @ajaykushwaha4233
    @ajaykushwaha4233 Рік тому

    Excellent

  • @letsbuildstuff7766
    @letsbuildstuff7766 3 роки тому

    very nicely explained

  • @og_in_ohio9605
    @og_in_ohio9605 4 роки тому +1

    Forgive me if I don't understand this correctly, but at 9min 20 seconds the data step has the do loop above the set statement. I would expect this to make a number of PDV's. Also the tot variable is not defined until you are in the loop.

    • @kiranvenna
      @kiranvenna  4 роки тому

      POINT= option inside a DO loop is designed to assign a different value to the POINT= variable on each iteration, so that random rows can be accessed. So do loop is not looping set statement but it is changing the value of variable in point=. NOBS =tot is set at compile phase and do loop works during execution phase, as tot variable is already created/available it can be used before set statement. Hope I am clear in explaining this.

  • @GoduruSaiteja
    @GoduruSaiteja Рік тому

    Hi Sir, May i know the reason, Why you did kept =0 in the MOD function (If Mod(_n_,3)=0). Can you please tell me sir. i

    • @kiranvenna
      @kiranvenna  Рік тому

      Mod function gives us reminder. Remainder = 0 here means means _n_ is completely divisible by 3.

    • @GoduruSaiteja
      @GoduruSaiteja Рік тому

      @@kiranvenna ok Thank you so much for the clarification and replied

  • @mummanenivanaja7116
    @mummanenivanaja7116 4 роки тому

    If we need 1 st and last record along with this every row of 3 record ,pls could u explain how can we extract??

    • @kiranvenna
      @kiranvenna  4 роки тому +4

      just need to include 1 and last record in do loop. try below query
      data class;
      do p=1, 3 to n-1 by 3, n;
      set sashelp.class point=p nobs=n;
      output;
      end;
      stop;
      run;

    • @mummanenivanaja7116
      @mummanenivanaja7116 4 роки тому +1

      Thank you sir.

  • @mummanenivanaja7116
    @mummanenivanaja7116 4 роки тому

    Hello sir ,if we have column like this var=xxxx yyy zz ,then I need where ever x is there then it has been replaced by and in the place of y i need 2 and in the place of z I need 3 ,this values are in single column ,so how can I do it ?? Pls can u suggest me ,

    • @kiranvenna
      @kiranvenna  4 роки тому

      I am.sorry it is not completely clear what you are asking for

    • @mummanenivanaja7116
      @mummanenivanaja7116 4 роки тому

      @@kiranvenna I have one column and value is like this "xxx yy z " so in this place I need 1 in the place of xxx and 2 in the place of yy and 3 in the place of z ,so finally 1 2 3 is my out put ,can u pls explain the logic

    • @kiranvenna
      @kiranvenna  4 роки тому +1

      One way to do this.
      data abc;
      a="xxx yy z";
      length B $10;
      retain B;
      do i=1 to countw(a);
      b=catx(" ", b, put(i, 3.));
      end;
      drop a i;
      rename b=a;
      run;

  • @adityabatra8894
    @adityabatra8894 3 роки тому

    All patient has 5 visit date . the query is the visit date is greater than previous visit date

    • @kiranvenna
      @kiranvenna  3 роки тому

      Please give a sample input and output so that I understand your problem better and help you

  • @shravyajasti1432
    @shravyajasti1432 4 роки тому +1

    Hello sir, Can you do a video on RETAIN statement ?
    And can you make some advanced macros videos ?
    Thanks!

    • @kiranvenna
      @kiranvenna  4 роки тому

      I will try. Please checkout this advance Macro Video ua-cam.com/video/63mWty9aZsA/v-deo.html

  • @ajaykushwaha4233
    @ajaykushwaha4233 Рік тому

    Anyone can help, what to to to keep records from 1, 4,7,10 n so on.

    • @kiranvenna
      @kiranvenna  Рік тому +1

      Try this.
      data a;
      set sashelp.class;
      justforcheck=_n_;
      if mod(_n_, 3)=1;
      run;