Jinhua Wang
Jinhua Wang

Reputation: 1759

SAS How to name file with Macro Numeric and String concatenated?

I am trying to export a csv file with the following code:

  proc export data=stock_params (obs=99999)
    outfile= &DATE_VAR||'param.csv'
    dbms=CSV REPLACE;
    putname=YES;
  run;

Where &DATE_VAR is a numeric value (such as 20130102) and 'param.csv' is a string of characters. I am trying to name the file in the format similar to 20130102param.csv, but I am not sure how to combine the characters and the numerical string. The above code didn't work, and I also tried the following way, which didn't work either:

  proc export data=stock_params (obs=99999)
    outfile= put(&DATE_VAR, 6.)||'param.csv'
    dbms=CSV REPLACE;
    putname=YES;
  run;

Therefore, I was wondering how to do this?

Upvotes: 0

Views: 54

Answers (1)

Reeza
Reeza

Reputation: 21294

Use double quotes to create a string. You need a period to end the macro variable and the remaining text.

Outfile = "&date_var.parm.csv"

Upvotes: 2

Related Questions