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

Hi,

 

Is there a way of creating a new variable e.g Checked and having all of the records have Y as the result in the checked variable, because I want this 'Y' flag to be apparent (for all records in this ac.list_Jan_Nov dataset) when I left join this dataset onto another dataset? Thanks!

 

data test;

   set ac.list_Jan_Nov;

   [What code to include here so that all records in ac.list_Jan_Nov dataset are selected?] .... then Checked='Y';

run;

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Is this what you want?

 

data want;
   set sashelp.class;
   retain Checked 'Y';
run;

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Is this what you want?

 

data want;
   set sashelp.class;
   retain Checked 'Y';
run;
jeremy4
Quartz | Level 8

Hi,

Thanks for the reply. 'Checked' is currently not a variable in my ac.list_Jan_Nov dataset, but I would like to create the new 'Checked' variable (that is why I wrote then Checked = 'Y'; in the code above) and have all of the records in the ac.list_Jan_Nov dataset have Y for the 'Checked' variable, as all of the records have been checked and when I left join this dataset, I will know that the records in this dataset have been checked. Would the RETAIN statement help to do this?

PeterClemmensen
Tourmaline | Level 20

Have you tried my code?

 

The variable checked is not in the SASHELP.CLASS data set either. The retain statement ensures that it has the value 'Y' for each record

Reeza
Super User
Did you try the code? Pretty sure that's what it does.

If you want it in SQL, its like this;

proc sql;
create table want as
select *, 'Y' as checked
from sashelp.class;
quit;
jeremy4
Quartz | Level 8
Perfect, thanks a lot for your help!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 568 views
  • 0 likes
  • 3 in conversation