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

Hello,

 

I have a problem about subsetting data.

 

I need to keep the observations where the variable A equals to "speech" from a dataset. Then I need to merge this new dataset with another dataset and keep the observations that are in both datasets.

 

It is appreciated if anyone can help me. Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Names cannot contain periods.  By using ORIG.SUB you told SAS to create a dataset named SUB in library pointed to by the libref ORIG.  

 

Names can use letter, digits and underscores.  They must NOT start with a digit.

View solution in original post

7 REPLIES 7
Reeza
Super User
Which step are you having problems with? It would probably help if you showed the code you tried with an explanation of what isn't working. You may need to provide sample data, but starting with the code is a good first step.
RebeccaJW
Calcite | Level 5
data orig;
	infile "/home/Projects/Project2/A/B_clean.csv" dsd missover firstobs=2;
	informat title name $10000. date MMDDYY10. ;
	format date DDMMYY10.;
    input title name date;
    
    if title = "NEW" then date = '31OCT12010'd;
    if title = "OLD" then date = '15JUN2008'd;	

run;

data orig.sub;
	set orig;
	where name="speech";
run;

This is what I have written. The first part works well, but in the orig.sub step, there is an error shown below:

 

ERROR: Libref ORIG is not assigned.

 

Thank you for replying!

Tom
Super User Tom
Super User

Names cannot contain periods.  By using ORIG.SUB you told SAS to create a dataset named SUB in library pointed to by the libref ORIG.  

 

Names can use letter, digits and underscores.  They must NOT start with a digit.

RebeccaJW
Calcite | Level 5
Thank you! It works now!
Reeza
Super User
data orig.sub;
	set orig;
	where name="speech";
run;

Did you create the ORIG library?

If not, just remove that portion of the name or declare the library first. The remainder of your code looks fine.

 

 

RebeccaJW
Calcite | Level 5
Thank you for replying! It works now!
Tom
Super User Tom
Super User

Sounds like you know what to do.

Post the code you created for each of those steps and if it generates errors the log from your attempt to run it. 

 

Remember to use the Insert Code button {i} on the gui to get a pop-up window to paste/edit the lines from the log. Otherwise the forum editor will re-flow the lines and make the log harder to read.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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