BookmarkSubscribeRSS Feed
Ani_Abby
Obsidian | Level 7

Hi. I have this piece of coding whereby I use Load_Dt which add using Prompt Manager with following info:

     Prompt type:                                     Date
     Method for populating prompt:             User enters value

     Number of values :                              Sing value

     Date type :                                        Day

     Options (which I choose) :               1) Requires a non-blank value               2) Use prompt value throughout project

%put &Load_Dt;

data _null_;
     initialdt = &Load_Dt.;

     call symput('initialdt',initialdt);
     call symput('initialdt_',initialdt_);
     call symput('DDMMYY',put(initialdt,DDMMYYN6.));
     call symput('YYYYMM',put(initialdt,YYMMN6.));
     call symput('YYYYQQ',put(initialdt,YYQ6.));
run;

%put &initialdt.;
%put &initialdt_.;
%put &DDMMYY.;
%put &YYYYMM.;
%put &YYYYQQ.;

Here is the log I got after running the program.

19         %put &Load_Dt;
31Aug2012
20         


21         data _null_;
22              initialdt = &Load_Dt.;
NOTE: Line generated by the macro variable "LOAD_DT".
22          31Aug2012
              _______
              22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, , =, >, >=, AND, EQ, GE, GT, IN, 
              LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.  
23
34              call symput('initialdt',initialdt);
25              call symput('initialdt_',initialdt_);
26              call symput('DDMMYY',put(initialdt,DDMMYYN6.));
27              call symput('YYYYMM',put(initialdt,YYMMN6.));
28              call symput('YYYYQQ',put(initialdt,YYQ6.));
29         run;

30         
31         %put &initialdt.;
put(31Aug2012,DDMMYY10.)
32         %put &initialdt_.;
.
33         %put &DDMMYY.;
.
34         %put &YYYYMM.;
.
35         %put &YYYYQQ.;
.

I don't which code goes wrong, is it date, macro or prompt. I really need big help on this. Usually I pre-code the date in as initialdt = '31AUG2012'd  which work perfectly but the user wants to choose their own date. Having the dataset that I need to choose name ended with &YYYYMM is not helping with the prompt.

Thank you so much.

1 REPLY 1
shivas
Pyrite | Level 9

Hi,

initialdt = &Load_Dt.;

change this to and try...

initialdt = "&Load_Dt"d;

Thanks,

Shiva

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2724 views
  • 0 likes
  • 2 in conversation