BookmarkSubscribeRSS Feed
ChrisWoo
Obsidian | Level 7

Hi guys, just wanna know what's wrong with my code.

I expect the outcome is written into log like following:

 

text = 31/07/2023
text = 31/08/2023
text = 30/09/2023
text = 31/10/2023
text = 30/11/2023
text = 31/12/2023
text = 31/01/2024
text = 29/02/2024

/* My code */

data _null_; do 1 = 0 to 7; put "text = " put(intnx("month","01Jul2023"d,i,"end"),ddmmyy10.); end; run;
1 REPLY 1
FreelanceReinh
Jade | Level 19

Hi @ChrisWoo,

 

Basically, the PUT statement works only with variables and string constants. Results of a function must be stored in a variable first.

data _null_;
do i = 0 to 7;
  text=put(intnx("month","01Jul2023"d,i,"end"),ddmmyy10.);
  put "text = " text;
end;
run;

With named output the PUT statement can be simplified to

put text=;

This doesn't put blanks around the equals signs, though.

 

Another option is formatted output:

data _null_;
do i = 0 to 7;
  d=intnx("month","01Jul2023"d,i,"end");
  put "text = " d ddmmyy10.;
end;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 746 views
  • 2 likes
  • 2 in conversation