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

I have a data set with a column that indicates poor sleep, but instead of filling in all of the cells, they only indicated "y" if the patient had poor sleep. 

 

How can I fill in the blank cells so they contain "n"?

 

I tried making a new column:

DATA polphar.Polypharm_DataV3;
SET polyphar.polypharm_data;
IF poor_sleep= "." then poor_sleepYN= "N";
IF poor_sleep= "y" THEN poor_sleepYN= "Y";
RUN;

 

But it keeps giving me this error: ERROR: Libref POLPHAR is not assigned.

I am using SAS University Edition. 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Actually, you just have a typo, not the y in one and not the other.

 

DATA polphar.Polypharm_DataV3;
SET polyphar.polypharm_data;

 


@DK13 wrote:

I have a data set with a column that indicates poor sleep, but instead of filling in all of the cells, they only indicated "y" if the patient had poor sleep. 

 

How can I fill in the blank cells so they contain "n"?

 

I tried making a new column:

DATA polphar.Polypharm_DataV3;
SET polyphar.polypharm_data;
IF poor_sleep= "." then poor_sleepYN= "N";
IF poor_sleep= "y" THEN poor_sleepYN= "Y";
RUN;

 

But it keeps giving me this error: ERROR: Libref POLPHAR is not assigned.

I am using SAS University Edition. 


 

 

View solution in original post

3 REPLIES 3
Reeza
Super User
if missing(poor_sleep) then poor_sleepYN="N";
else poor_sleepYN = upcase(poor_sleepYN);
Reeza
Super User

Actually, you just have a typo, not the y in one and not the other.

 

DATA polphar.Polypharm_DataV3;
SET polyphar.polypharm_data;

 


@DK13 wrote:

I have a data set with a column that indicates poor sleep, but instead of filling in all of the cells, they only indicated "y" if the patient had poor sleep. 

 

How can I fill in the blank cells so they contain "n"?

 

I tried making a new column:

DATA polphar.Polypharm_DataV3;
SET polyphar.polypharm_data;
IF poor_sleep= "." then poor_sleepYN= "N";
IF poor_sleep= "y" THEN poor_sleepYN= "Y";
RUN;

 

But it keeps giving me this error: ERROR: Libref POLPHAR is not assigned.

I am using SAS University Edition. 


 

 

DK13
Calcite | Level 5

Good catch! Thanks!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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