Hello
I have a raw data set with one row per each customer .
Each row has multiple columns : customer_ID,X1,X2,X3.....X100.
Each Column (X1,X2..X100) is numeric (categorical values) with numeric format.
For example:
Column X1 get values: 1(Yes) ,0 (No)
Column X2 get values: 1(EU) ,2 (USA),3 (Africa),4(Australia)
I want to write a program that do the following:
A-User define list of varaibles that he is interested (In a macro varaible)
B-Calculate Information value for each varaible in the list and show the distribtuion of each category
The output will be presented in one summary table.
The categories values will be displayed by their format and not by their values (In order to understand what is the meaning of each value)
Please see example of the data:
May anyone show a program that perform the required task
proc format;
value f1ff
1='Yes'
2='No'
;
value f2ff
1='EU'
2='USA'
3='Africa'
4='Australia'
;
value f3ff
1='a3'
2='b3'
3='c3'
;
value f4ff
1='a4'
2='b4'
3='c4'
;
value f5ff
1='a5'
2='b5'
3='c5'
4='d5'
;
Run;
Data ttt;
Retain Id X1 X2 X3 X4 X5;
Format X1 f1ff. X2 f2ff. X3 f3ff. X4 f4ff. X5 f5ff.;
Input ID x1 x2 x3 x4 x5 Ind_Fail;
label
ID='Customer ID'
X1='Team'
X2='Indicator big/small'
X3='Light strength'
X4='Location'
X5='Country'
;
cards;
6 1 4 3 2 4 1
1 2 1 3 1 2 0
4 1 3 3 2 1 0
2 1 2 2 1 2 0
3 1 2 1 2 3 1
5 2 3 2 3 2 0
7 2 2 1 2 1 1
;
Run;
Which calculation do you want? You don't mention. When placing everything in "one table" you do need to specify as the likely approaches depend on what that table is supposed to look like and what it contains.
Is the real question how the user specifies the variables?
User specify the required varaibles in a macro varaible.
For example:
%let List=X1 X2 age wealth x35 w z race ;
@Ronein wrote:
User specify the required varaibles in a macro varaible.
For example:
%let List=X1 X2 age wealth x35 w z race ;
Okay.
So what calculations are involved? Still not stated.
If you know the variables involved you should have a reference for their formats and you assign them. Such as a data set. Build a format statement from the list and that data set.
Or make sure the format is associated with the variables every where it may be used. If you expect the users to specify a different format for different uses then you are in another level of complexity.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.