BookmarkSubscribeRSS Feed
JHE
Obsidian | Level 7 JHE
Obsidian | Level 7

I have this SAS code,

 

why Merge the last step dose not working:

 

PROC SORT DATA=REWK0.REWORK0500_CODECOUNT;

BY LOB Category Code CODE_DESCRIPTION;

RUN;

 

PROC SORT DATA=REWK0.Paid0500TRANS OUT=Paid0500TRANS;

BY LOB Category Code CODE_DESCRIPTION;

RUN;

 

DATA work.REWORK0500_codecount;

MERGE REWK0.REWORK0500_CODECOUNT Work.Paid0500TRANS;

BY LOB Category Code CODE_DESCRIPTION;

RUN;

5 REPLIES 5
Kurt_Bremser
Super User

Define "not working". "Does not work" is about as useful as the proverbial message about the sack of rice in China.

Post the log, and example of data and results not matching your expectations.

If you want us to test code, post example data in data steps.

PeterClemmensen
Tourmaline | Level 20

What does the error message in your log say?

Shmuel
Garnet | Level 18

Your code should work unless you have a typo in dataset names or vaiables names..

Check your datasets spelling and if you have still issues post your log.

Astounding
PROC Star

This code can fail if one of your BY variables meets these conditions.  The variable is character, and has different lengths in the two incoming data sets.

 

The log should contain a warning about this, a warning which is fatal in this case.  The solution is simple.  Add a LENGTH statement before the MERGE statement, using the longer length from the two data sets.  For example:

 

DATA work.REWORK0500_codecount;

length code $ 10;

MERGE REWK0.REWORK0500_CODECOUNT Work.Paid0500TRANS;

BY LOB Category Code CODE_DESCRIPTION;

RUN;

ballardw
Super User

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 810 views
  • 0 likes
  • 6 in conversation