这是我的code:
data INDAT8; set INDAT6;
Array myarray{24,27};
goodgroups=0;
do i=2 to 24 by 2;
do j=2 to 27;
if myarray[i,j] gt 1 then myarray[i+1,j] = 'bad';
else if myarray[i,j] eq 1 and myarray[i+1,j] = 1 then myarray[i+1,j]= 'good';
end;
end;
run;
PROC打印数据= INDAT8; 运行;
proc print data=INDAT8; run;
问题:
我有数据在这个格式化,这只是一个例子:n = 2的 X Y信息
I have the data in this format- it is just an example: n=2 X Y info
2 1 good
2 4 bad
3 2 good
4 1 bad
4 4 good
6 2 good
6 3 good
现在,上面的数据是按排序方式(共7行)。我需要的一组2,3或4行分别与生成的曲线图。另外,在上述的数据,我提出的一组2行。第三行被单独留下,因为这里在第三行没有其它列,以形成一个组。可仅在相同的行形成的基团。不与其它的行。
Now, the above data is in sorted manner (total 7 rows). I need to make a group of 2 , 3 or 4 rows separately and generate a graph. In the above data, I made a group of 2 rows. The third row is left alone as there is no other column in 3rd row to form a group. A group can be formed only within the same row. NOT with other rows.
现在,我将检查这两个行具有好在信息栏与否。如果这两个行具有好 - 构成的组还不错,否则不好。在上面的例子中,第三/最后一组是好的基团。其余的都是不好的组。有一次,我正在与所有的行做的,我会计算总没有。良好的团体形成/总数。的基团。
Now, I will check if both the rows have "good" in the info column or not. If both rows have "good" – the group formed is also good , otherwise bad. In the above example, 3rd /last group is "good" group. Rest are all bad group. Once I’m done with all the rows, I will calculate the total no. of Good groups formed/Total no. of groups.
在上面的例子中,输出将是:总无。优秀组/总数。基的=> 1/3
In the above example, the output will be: Total no. of good groups/Total no. of groups => 1/3.
这是n的情况下= 2(组大小)
This is the case of n=2(size of group)
现在,对于n = 3,我们使组3行对于n = 4,我们使一组4行,找到好的/坏的基团以类似的方式。如果在一个组中的所有行具有良好块的结果是好块,否则不好。
Now, for n=3, we make group of 3 rows and for n=4, we make a group of 4 rows and find the good /bad groups in a similar way. If all the rows in a group has "good" block—the result is good block, otherwise bad.
Example: n= 3
2 1 good
2 4 bad
2 6 good
3 2 good
4 1 good
4 4 good
4 6 good
6 2 good
6 3 good
在上述情况下,我离开了第4行和最后2行,因为我不能让3行与他们组。第一组的结果是坏和最后一组的结果是良好。 输出:1 /
In the above case, I left the 4th row and last 2 rows as I can’t make group of 3 rows with them. The first group result is "bad" and last group result is "good". Output: 1/ 2
For n= 4:
2 1 good
2 4 good
2 6 good
2 7 good
3 2 good
4 1 good
4 4 good
4 6 good
6 2 good
6 3 good
6 4 good
6 5 good
在这种情况下,我让一组4,并发现的结果。第5,第6,第7,第8行被留下或忽略。我做2组,每组4行,无一不是好的块。 输出:2/2
In this case, I make a group of 4 and finds the result. The 5th,6th,7th,8th row are left behind or ignored. I made 2 groups of 4 rows and both are "good" blocks. Output: 2/2
所以,从N = 2,N-3使用3的输出值,和n =后4我将绘制这些值的曲线图。
So, After getting 3 output values from n=2 , n-3, and n=4 I will plot a graph of these values.
如果您可以帮助任何使用数组,如果做循环的任何语言。这将是巨大的。
If you can help in any any language using array, if and do loop. it would be great.
我可以相应地改变我的code。
I can change my code accordingly.
更新
有此答案不必在SAS。因为它更算法相关的比什么都重要,我会接受建议的任何语言,只要他们展示如何做到这一点使用数组和不要
。
The answer for this doesn't have to be in sas. Since it is more algorithm-related than anything, I will accept suggestions in any language as long as they show how to accomplish this using arrays and do
.
推荐答案
我无法理解你的问题的陈述,但是从我可以在这里收集是我可以建议:
I am having trouble understanding your problem statement, but from what I can gather here is what I can suggest:
将数据置于箱和过程中的汇总数据。
Place data into bins and the process the summary data.
实施1
假设:你不知道什么是第一列的范围将会或distriution将稀疏
Assumption: You don't know what the range of the first column will be or distriution will be sparse
创建一个哈希表。关键是你正在做你的分组上的项目。该值将是迄今看到计数。 PROCES每个记录。如果键已经存在,增加计数(值的散列键)。否则,添加项和值设置为1。 继续,直到处理完所有记录 计数密钥的哈希表中的数目和是大于你的阈值的数量。实施2
假设:你知道第一列的范围和distriution是相当密集的
Assumption: You know the range of the first column and the distriution is reasonably dense
创建具有足够元素的整数数组因此指数可以匹配的列值。初始化所有元素为零。这个阵列会牵着你的清点每件物品你上进行分组 在处理每个记录。检查第一列的值。在阵列增量对应的索引。 (所以,如果你有2 1好,做groupCount [2] ++) 继续,直到处理完所有记录 步行数组中的每个元素。指望有多少项目是非零(这意味着他们至少出现一次)以及有多少项符合您的门槛。您可以使用同样的方法收集好的和坏的计数。
You can use the same approach for gathering the good and bad counts.
相关推荐
最新文章