BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Thylacine
Fluorite | Level 6

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?

 


error.png
1 ACCEPTED SOLUTION

Accepted Solutions
Thylacine
Fluorite | Level 6

ok got it. Yes i forgot to put the macro in " "  and the informat i needed was ANYDTDTM. Thanks for help.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

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.

Thylacine
Fluorite | Level 6

ok got it. Yes i forgot to put the macro in " "  and the informat i needed was ANYDTDTM. Thanks for help.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 841 views
  • 0 likes
  • 2 in conversation