BookmarkSubscribeRSS Feed
sfmeier
Obsidian | Level 7

Dear experts,

in a DATA step I am using the substr function on a $10. formatted variable that contains numbers.The numbers begin with 5, however substr(variable,1,1) returns 6 :smileyalert:

How can I make it work?

Thank you,

Stefan

4 REPLIES 4
Linlin
Lapis Lazuli | Level 10

please post a few observations from your dataset.

sfmeier
Obsidian | Level 7

Here u go! Like this? RT_Kusy RT_RespOrg substr_rt_kusy SG_WP 52102007 BBO_I_P 6 1 52102007 BBO_I_P 6 1 52102007 BBO_I_P 6 1 52102007 BBO_T_P 6 1 52102011 BBO_I_P 6 1 52102007 BBO_T_P_CV 6 1 52100011 BBO_T_P 6 1 52102007 BBO_I_P 6 1 52100011 BBO_I_P 6 1 52100011 BBO_I_P 6 1 52102007 BBO_I_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_I_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_I_P 6 1 52102007 BBO_I_P 6 1 52102007 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_T_P 6 1 52100011 BBO_I_P 6 1 52102007 BBO_I_P 6 1 50102008 BBO_T_P 6 1 52102007 BBO_T_P 6 1

art297
Opal | Level 21

You will have to show the code you are using to input the data and the code you are using to incorporate the substr function.  It appears like you are only declaring four fields, but either have five fields or one that includes space separated data.

sfmeier
Obsidian | Level 7

Ups, I just found my error myself, thx anyway!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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