BookmarkSubscribeRSS Feed
claremc
Obsidian | Level 7

Hello, 

 

I realized that people with middle names or suffixes in my data, i.e.: "Jane Doe PHD" or "Bob Scott Jr" are getting their data pushed so that for only these people, all of their data is being shifted one column to the left. This is only happening to these people, and my dataset comes from an outside source library (and cannot changed from the source).  The solutions I've seen are mainly related to changing data when you in the infile statement when you load the data in, which is not possible for me. Let me know, thanks! 

 

Again, I want to do something like this : 

if index(First_name2, "JR" "PHD") then [SOMEHOW-SHIFT-LEFT COLUMNS 4 THRU 11];
1 REPLY 1
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @claremc 

We need a listing of the variable attributes, because values should be moved from one variable to another, so differences in variable lengths and types might be a problem. So please submit the code "proc contents data=mylib.myinput; run;" and post the result.

 

It would also be a help to have a data sample, ex. the result of "proc print data=mylib.myinput(obs=10); run;". 

 

And a tip: To check for the occurrence of texts like "JR" or "PHD" is not the best way of finding the erroneus observations. It would be better to look at the variables 5-11 to see if a zip-code or other easily recognizable value is present in e.g. v8 or v9, or to check for non-missing values in v11, but that would only work if there are non-missing values in all observations. 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1 reply
  • 938 views
  • 0 likes
  • 2 in conversation