0
votes

I want to create a unix utility to insert 1 row into a sas dataset. When run, this scipt will ask user to insert value for each variable in the dataset(preferabely telling him the type and length of the variable). It will then pass these values to SAS using EXPORT command and then SAS will create macro variable for these variables and using 'proc sql; insert into' will insert the value into dataset.

data raw_str;
 /* init PDV */
 if 0 then
 set tracking_data;
 /* programmatic structure to enable addressing of vars */
 array a_c(*) _character_;
 array a_n(*) _numeric_;
run;

now raw_str will variables whose type and length be same as that of the tracking data

proc sql noprint;
  select distinct name 
  into : varlist separated by ' '
  from dictionary.columns
  where libname='WORK'
    and memname='raw_str';
quit;

then i want to pass this list to unix, from there i will ask user to enter value for these variables and then i will append these values into the tracking_data using.

problem is with passing values from unix to sas and creating macro variables for these values

I can also pass the length and type of variable to the front end, telling user to pass value which matched the type and length of raw_str dataset

proc sql;
  insert into raw_str
  values (&val1, &val2, &val3...);
quit;

finally i can use proc append to append it into the original data

1

1 Answers

0
votes

Here's one possible approach for getting user-entered values from UNIX into SAS:

  1. Have your UNIX shell script write out the user-entered values into a (consistently formatted) temporary text file, e.g. CSV
  2. Write a SAS data step that can read the text file and import the values into the required formats. You can run proc import and look at the log to get an idea of the sort of code to use.
  3. Have the script call SAS via the command line, telling it to run a program containing the data step you wrote.