BookmarkSubscribeRSS Feed
Nikster
Calcite | Level 5

Hi,

 

I want to enter a "-" after 2 numbers in a column for all numbers.

 

Examples: All numbers in the column are like 1234567, and I want to add "-" after 2 numbers to look like 12-34567

 

Please help.

 

Thanks

5 REPLIES 5
PaigeMiller
Diamond | Level 26

Is your 1234567 a numeric or a character variable? 

--
Paige Miller
Nikster
Calcite | Level 5

Numeric

Astounding
PROC Star
Use a picture format:

proc format;
picture dash 1000000 - 9999999 = '12-34567';
run;

Then print the variable using the format:

format varname dash. ;
Nikster
Calcite | Level 5

I have a column with multiple numbers like -

 

12-34567

78-465697

102-589865

78-56546

 

I just to remove the dash ('-") between the numbers, so it another column (calculated) looks like -

 

1234567

78465697

102589865

7856546

 

Cheers

PGStats
Opal | Level 21

Use the compress() function.

PG

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!

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.

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
  • 598 views
  • 1 like
  • 4 in conversation