05-16-2016 02:53 AM
I've output 'Moments' from Proc Univariate to datasets. Many.
Example: Moments_001.sas7bdat through to Moments_237.sas7bdat
For the first column of each dataset (new added first column, and probably new dataset, as opposed to the original) I would like to have a particular text in every cell going down to bottom row.
The exact text would be the name of the respective dataset file: say, "Moments_001".
I do not have to 'grab' the filename, per se, if that's not possible. As I know what the names are already, I can put that text into the procedure. However, grabbing the filenames, if possible, would be easier from my standpoint.
I'd greatly appreciate any help anyone could provide to accomplish this.
05-16-2016 03:08 AM
There's the INDSNAME option.
Are you you planning to append the files? If so, something like the following should work.
Data moments_all; Set moments_1 - moments_237 indsname=source; Dataset_source = source; Run;
05-16-2016 07:12 AM
To make your new variable appear as the first column, also add a LENGTH statement:
length dataset_source $ 32;
set moments_1 - moments_237 indsname=source;
dataset_source = source;
The LENGTH statement must come before the SET statement for this to work properly.
05-16-2016 04:28 AM
Why have you created hundreds of datasets? One of the prime benefits of SAS is that it allows you to process datasets using by groups - hence one dataset can contain many by groups. This is both faster (open file once), and far simpler to work with. My suggestion is to look at the process up to an including the univariate, and fix that so you have one dataset to work with.