turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-27-2014 08:10 AM

Hi, I would like to make such a version of this function 'mhatx1' which omits x=i from the sum i.e. computes t4

start mhatx1(m,p,h,pi,e);

t4=j(m,1);

do x=1 to nrow(p);

i=T(1:m);

temp1=x-i;

ue=Kmod(temp1,h,pi,e)#p*;*

le=Kmod(temp1,h,pi,e);

t4

end;

return (t4);

finish;

Accepted Solutions

Solution

06-27-2014
10:09 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to LauriN

06-27-2014 10:09 AM

If I understand your quetion, there are several ways to accomplish what you are asking. The method to choose depends on whether you want to modify the computation of ue and le, or just the sums.

Here are some functions that are good to know about:

- The REMOVE function. You can use this function if you want to remove certain elements from temp1. For example, the zero always occurs at the x_th position, so the following statement modifies temp1 so that it contains m-1 elements:

temp1=remove(x-i,x); /* exclude 0 from elements */ - The LOC function: Although it is not necessary here, you might need to find the indices of the elements tot satisfy some criterion before you can remove them. The LOC function enables you to find the elements. For details, see Finding data that satisfy a criterion - The DO Loop

I think the REMOVE function is all you need here.

All Replies

Solution

06-27-2014
10:09 AM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to LauriN

06-27-2014 10:09 AM

If I understand your quetion, there are several ways to accomplish what you are asking. The method to choose depends on whether you want to modify the computation of ue and le, or just the sums.

Here are some functions that are good to know about:

- The REMOVE function. You can use this function if you want to remove certain elements from temp1. For example, the zero always occurs at the x_th position, so the following statement modifies temp1 so that it contains m-1 elements:

temp1=remove(x-i,x); /* exclude 0 from elements */ - The LOC function: Although it is not necessary here, you might need to find the indices of the elements tot satisfy some criterion before you can remove them. The LOC function enables you to find the elements. For details, see Finding data that satisfy a criterion - The DO Loop

I think the REMOVE function is all you need here.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Rick_SAS

06-29-2014 09:55 AM

Thank you! That REMOVE was what I was looking for, even though I just ended up removing t'th solutions of the inner functions ue and le from summations:

start mhatx2(m,p,h,pi,e);

t5=j(m,1);

do x=1 to nrow(p);

i=T(1:m);

temp1=x-i;

ue=Kmod(temp1,h,pi,e)#p*;*

le=Kmod(temp1,h,pi,e);

t5

end;

return (t5);

finish;