How to pick every third row in SAS
Vložit
- čas přidán 22. 08. 2024
- How to use _n_, mod function, nobs= and point=. to keep the observations . If you like this video, please feel free to like, share, comment and subscribe.. For any queries, please contact us at smarttech089@gmail.com
Nicely explained👍
Excellent
very nicely explained
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.
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.
All patient has 5 visit date . the query is the visit date is greater than previous visit date
Please give a sample input and output so that I understand your problem better and help you
Hello sir, Can you do a video on RETAIN statement ?
And can you make some advanced macros videos ?
Thanks!
I will try. Please checkout this advance Macro Video czcams.com/video/63mWty9aZsA/video.html
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
Mod function gives us reminder. Remainder = 0 here means means _n_ is completely divisible by 3.
@@kiranvenna ok Thank you so much for the clarification and replied
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 ,
I am.sorry it is not completely clear what you are asking for
@@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
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;
If we need 1 st and last record along with this every row of 3 record ,pls could u explain how can we extract??
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;
Thank you sir.
Anyone can help, what to to to keep records from 1, 4,7,10 n so on.
Try this.
data a;
set sashelp.class;
justforcheck=_n_;
if mod(_n_, 3)=1;
run;