BookmarkSubscribeRSS Feed
kalbo
Obsidian | Level 7

Hi,

 

I'm trying to write some code that will scan pseudo sas code stored in a mapping sheet which merges or concatenates data sets.

 

In example 1 I want to see if there is "data" followed by "merge" and "run".

 

The lines "ANY TEXT..." just mean that any other code or text may be present in those lines.

 

Thanks.

 

****example 1****

ANY TEXT DKASJLFLDLSAJFKLDFJD;
DATA NEW;
MERGE DSONE(IN=A) DSTWO(IN=B);
RUN;
ANY TEXT DKASJLFLDLSAJFKLDFJD;

 

In example 2 I want to see if there is "data" followed by "set" followed by at least 2 data sets, and want to ignore the (in=) parts.

****example 2****

ANY TEXT DKASJLFLDLSAJFKLDFJD;
DATA NEW;
SET DSONE(IN=X) DSTWO(IN=Y) DSTHREE;
RUN;
ANY TEXT DKASJLFLDLSAJFKLDFJD;

 

In example 3 I want to see if there is "proc sql" followed by "join" and "quit"

****example 3****

ANY TEXT DKASJLFLDLSAJFKLDFJD;
PROC SQL;
select customers.city, sales.totals
from sales natural inner join customers
where country='United States';
QUIT;
ANY TEXT DKASJLFLDLSAJFKLDFJD;

1 REPLY 1
ballardw
Super User

Followed how closely for cases one and two?

A data step may any number of statements before a Set or Merge depending on coding style. For example you might have someone assign a bunch of lengths, formats or labels for some reason.

 

There are also some techniques with multiple SET statements that are used to combine/interleave more than one data set.

 

Does every single data step end with a Run? If not you may be opening can worms for logic.

 

And for a truly memorable question, what does the expected output from the process look like? I have no idea what you may want/expect the output to look like.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 326 views
  • 0 likes
  • 2 in conversation