07-03-2017 10:54 AM - edited 07-03-2017 10:59 AM
I have z macro variable with date inside (2017-07-03 10:08:03) when i try to use it like this: variable=Scan(&data_z_nazwy,1,' ')
i get an error (in attachment). Got it also when trying in various ways to change it to date format. Can someone suggest a way to assign it to a variable with datetime format?
07-03-2017 10:58 AM - edited 07-03-2017 11:02 AM
The most likely change is this:
variable = scan("&data_z_nazwy", 1, ' ');
SAS language requires quotes around character strings, to recognize that they are character strings. Double quotes (not single) are required here. Single quotes would prevent resolution of the macro variable into its value.
Related questions: You attempted to read the first word (the date part) using SCAN. That creates a character variable, not a date variable. So this change follows along those lines and creates a character variable. If you actually wanted a date:
date_variable = input("&data_z_nazwy", yymmdd10.);
format date_variable yymmdd10.;
And if you actually wanted a date-time variable, yet a different formula would be required.
Need further help from the community? Please ask a new question.