Dear all,
If i,ve a dataset containing one variable with the obsevations 1-20 (say) from this dataset 2 subjects withdrawn 9, 16 (say) and i've choosen a random no. (say 18), now i need the output starting from 18 to 20% of data(when reached end of obs. then start from first like 18,20,1,2)
thanks in advance.
Sorry, I can't follow your logic. Post have data (in terms of a datastep) and required output. If you want loops then look at do loops.
I don't understand how the first part of your question relates to the second part.
Below a code sample for the second part of your question how I understand it.
data have;
do var=1 to 20;
output;
end;
stop;
run;
data select(drop=_:);
_start=ceil(ranuni(0)*_nobs);
do _i=_start to _nobs;
_counter+1;
if _counter>4 then leave;
set have nobs=_nobs point=_i;
if _i=_nobs then _i=0;
output;
end;
stop;
run;
thanks, it could be very helpful.
Giving decimal places and significant digits in SAS
Dear all,
i've a dataset like given bellow
A | B | C | D |
---|---|---|---|
N | 36 | 36 | 36 |
Mean | 9581.1728 | 9791.5262 | 1366.1106 |
SD | 2965.8626 | 2982.0749 | 398.3543 |
Geo_Mean | 9170.2867 | 2.0864674 | 1312.3213 |
CV | 13.95511 | 13.455669 | 0.159741 |
Now i need to give 3 decimal places for the variables 'B' & 'C', and 5 significant digits for the variable 'D'. But these decimal places and significant digits should not be applyed for observations of 'N'. i had tried many things like format, length and etc. but it didn't work well. the output should be like given bellow.
A | B | C | D |
---|---|---|---|
N | 36 | 36 | 36 |
Mean | 9581.172 | 9791.526 | 1366.1 |
SD | 2965.862 | 2982.074 | 398.35 |
Geo_Mean | 9170.286 | 2.086 | 1312.3 |
CV | 13.955 | 13.455 | 0.15974 |
i'm excited to find is it really possible? if so, can anyone tell me how? or it is possible by transforming the variables?
Thanks in advance
The most direct way is changing these variables into character variables .
The alternative way is using proc format or proc report + call define().
Xia Keshan
data have;
do var=1 to 20;
output;
end;
stop;
run;
data select;
array x{0:999999} _temporary_;
n=-1;
do until(last);
set have end=last;
n+1;x{n}=var;
end;
do i=18 to 21;
want=x{mod(i,20)}; output;
end;
keep want;
stop;
run;
Xia Keshan
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.