我想找到每个变量子集组合的唯一ID的数量。例如
data have;
input id var1 var2 var3;
datalines;
5 1 0 0
5 1 1 1
5 1 0 1
5 0 0 0
6 1 0 0
7 1 1 1
8 1 0 1
9 0 0 0
10 1 0 0
11 1 0 0
12 1 . 1
13 0 0 1
;
run;
我希望结果是
var1 var2 var3 count
. . 0 5
. . 1 5
. 0 . 7
. 0 0 5
. 0 1 3
. 1 . 2
. 1 1 2
0 . . 3
0 . 0 2
0 . 1 1
0 0 . 3
0 0 0 2
0 0 1 1
1 . . 7
1 . 0 4
1 . 1 4
1 0 . 5
1 0 0 4
1 0 1 2
1 1 . 2
1 1 1 2
这是附加所有可能的proc sql的结果;分组依据(下面显示了var1)
proc sql;
create table sub1 as
select var1, count(distinct id) as count
from have
where not missing(var1)
group by var1
;
quit;
我不在乎所有变量均缺失或分组依据中的任何变量均缺失的情况。有更有效的方法吗?
答案 0 :(得分:2)
您可以使用 class Program
{
static void Main(string[] args)
{
IntializeDictionary();
}
private static void IntializeDictionary()
{
Dictionary<char, MorseMapping> _morseAlphabetDictionary = new Dictionary<char, MorseMapping>()
{ {'a',new MorseMapping(".-", @"C:\myPath\fileForA.wav") }
//.. here goes the rest
};
_morseAlphabetDictionary['a'].Player.Play();
}
public class MorseMapping
{
public string MorseLetter { get; set; }
public SoundPlayer Player { get; set; }
public MorseMapping(string letter, string filePath)
{
this.MorseLetter = letter;
this.Player = new SoundPlayer(filePath);
}
}
}
来按组计算每个Proc SUMMARY
的{{1}}值的组合。在var1-var3
输出中,id
查询可以计算每个组合的不同ID。
示例:
SUMMARY