BookmarkSubscribeRSS Feed
astha8882000
Obsidian | Level 7

I read this line of code somewhere, I understand that the variable 'Memo' is initialized  to the value 'Aug 16', what is the purpose of '@'?

 

Also, the user usually goes in and updates the date everyday. Instead of doing that, isn't turning that into a macro variable a better option?

 

%let Memo = %sysfunc(today());

2 REPLIES 2
ChrisHemedinger
Community Manager

I'm not familiar with that @ symbol in an assignment statement -- but it could be a piece of esoteric legacy that someone else could weigh in on.

 

The most common use of the @ symbol to control assignments is in the INPUT statement, using it to advance the input pointer to a specific part of the input stream.  In this example, the @ operator tells SAS to find the pattern "Memo" and then reads the value just beyond that point. 

 

data test;
  length date 8;
  informat date date9.;
  format date date9.;
  infile datalines;
  input @ "Memo" date;
datalines;
Here's the Memo 16Aug2017
Another Memo 16Nov2018
Final Memo 15Oct2014
;
run;

 

op.png

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
ballardw
Super User

@astha8882000 wrote:

I read this line of code somewhere, I understand that the variable 'Memo' is initialized  to the value 'Aug 16', what is the purpose of '@'?

 


Showing the entire code would be better since the '@' can play a number of different roles in reading data.

 


 

Also, the user usually goes in and updates the date everyday. Instead of doing that, isn't turning that into a macro variable a better option?

 

%let Memo = %sysfunc(today());


Since on 2 May 2018 the macro variable Memo received the value with that call of 21305, likely not the optimal solution.

You would have to use sufficient SAS functions to make the macro variable appear exactly as the value appears in your data set.

This might get you started:

Data _null_;
   str=catx(' ',put(today(),monname3.),day(today()));
   call symputx('memo',str);
run;

but may need tweeking if the day part of your search string should be Aug 01 instead of Aug 1.

 

Don't forget to use "&memo." for the string to resolve properly.

 

 

Note that I find a data set that has to be read this way if only one variable uses it to be very problematic

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1050 views
  • 0 likes
  • 3 in conversation