BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Emma2021
Quartz | Level 8
I have a variable year as 4 digits string, for example, 2000,2001, 2002 etc.
I would like to loop over those values over year variable and print in log if I find 2002. How can I do that? Thank you.
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User
Data _null_;
    set have;
    if year=2000 then put name=;
run

If you mean to print the value of the variable NAME to the log when year is 2000.

 


@Emma2021 wrote:
Sorry, I want to check the name for the year=2000. So, if I find year=2000, then I want to print out in log whatever value has the variable “name”. Thank you

 

View solution in original post

5 REPLIES 5
Reeza
Super User
Why? There are easier ways? What are you ultimately trying to do....
Emma2021
Quartz | Level 8
I want to check only the log.
Emma2021
Quartz | Level 8
Sorry, I want to check the name for the year=2000. So, if I find year=2000, then I want to print out in log whatever value has the variable “name”. Thank you
ballardw
Super User
Data _null_;
    set have;
    if year=2000 then put name=;
run

If you mean to print the value of the variable NAME to the log when year is 2000.

 


@Emma2021 wrote:
Sorry, I want to check the name for the year=2000. So, if I find year=2000, then I want to print out in log whatever value has the variable “name”. Thank you

 

Reeza
Super User
proc print data=have(where =(year=2000));
var name;
run;

Why would you use the log for that type of functionality? Wouldn't results or some other output be more useful?

 

 

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 5 replies
  • 2586 views
  • 4 likes
  • 3 in conversation