02-10-2012 08:02 AM
I imported a csv file in SAS 9 and created a composite index from two variables using the following command:
proc datasets library=Work;
index create comp=(da1 da2);
It was successful with a note: "Composite index comp has been defined".
But the problem is I cannot export the modified dataset with the composite index included. I have export option from file menu and also tried the following command to export:
proc export data=Work.NewFile
But all I get is the original data (csv) file which I imported without the composite index created. I am in urgent need to solve this problem quickly and thereby looking forward to any responses. If you have any suggestion in creating composite variables/index in any other methods, please provide.
02-10-2012 01:30 PM
The index is not stored in the dataset itself, so there is nothing to export.
What you need to do is to just create a composite variable, something like
assuming DA1 and DA2 are character variables. You would need other data transformations for other data types.
Then the variable is in the file and available for export. BTW, just because you have an index does not change the order of the data in the export. To do that you need to sort the dataset.
02-11-2012 10:22 AM
Thanks for your reply.
I tried this according to you suggestion:
proc datasets library=Work;
But I'm getting the following error in the log:
53 modify New;
NOTE: Enter RUN; to continue or QUIT; to end the procedure.
ERROR 180-322: Statement is not valid or it is used out of proper order.
My variables contain both positive and negative numericals. Is the command I've tried is correct? Can you please tell me what process SAS uses to create composite variables (I meant what calculations it does to arrive at a single value using two values).
02-13-2012 03:49 AM
I believe 'comp' is meant to be a normal SAS variable which you would create in a data step.
Length comp $ <some value>;
...and then your process export stuff.
02-13-2012 10:21 PM
Thanks for the suggestion. I did it and it was successful but with typing the file name instead of 'have'. I can see from the output file that it creates composite variable by just placing the value of two variables side by side. The resulting composite variable has values very different from rest of the data. I thought composite variables are created by some mean of calculation using averages, variances, etc., and the resulting values looks alike with the rest. Also, the variances may have to be similar to the original values in each variable as very different variances result in error in structural equation modelling. I didn't find any other program but SAS to create composite variable. I'm not an expert in these issues, so any suggestions will be very much helpful.
02-12-2012 10:55 PM
Index is binded with dataset ,only contain the logic order for value of variate.
You can't export index with csv file. I do not understand what you do and what you want.
02-13-2012 02:20 AM
Thanks for viewing my problem. Using SAS, I want to create a composite variable/index from two variables both of which are interval type data (may contain positive and negative values). As I want to use this composite variable in regression, I need to save or export the created composite variable/index. This is what I couldn't do. Also, is the anyway to view the dataset in SAS which is exported?
02-13-2012 12:12 PM
I think that I see what is going on. "index" is a word that, in English, has multiple meanings (see http://dictionary.reference.com/browse/index for an exhaustive list).
"index", as used by SAS, is a computer science term that relates to how one orders data logically in the computer (definition 7 in reference, above)
"index", as you have just used above, is a score or algorithm. An example would be the "Dow-Jones Index" for the US Stock Market (definition 11)
In the second sense, you just use the DATA step (as Patrick described) or PROC SQL to create your score.
02-15-2012 06:24 PM
Do you mean veiw the SAS dataset before export? There are a variety of ways depending on your installation.
If you can find the library in the SAS Explorer clicking on the icon of the desired set should open it.
Or from a SAS command line type VT libname.datasetname (VT short for Viewtable). If you want to sort or edit values in the set then add the option OPENMODE=EDIT after the VT command.
If you have the SAS AF module license FSVIEW is another tool to look at datasets.
02-15-2012 11:07 PM
Can you explain more what you mean by "composite" variable? Do you already have an algorithm for combining the two variables to form a new value?
Or perhaps you are looking to calculate a statistic instead of just doing a arithmetic operation?
02-18-2012 12:46 AM
By composite variable I meant to create a variable from two or more than two variables which will show similar trait as the component variables. This I will use in LISREL to develop SEM. The latent variables I created would be the composite variables of its indicators. I don't have an algorithm and I want to calculate of statistic as you said in the latter. Thank you.