BookmarkSubscribeRSS Feed
Phill
Calcite | Level 5

Hey there,

I looked around and I found a few suggestions such as https://communities.sas.com/thread/30121?start=0&tstart=0. However, I have a slightly different scenario and I cannot figure it out by myself.

The observations are saved in a SAS dataset in one char variable like 5' 10, 6' 4" ... etc. The problem I ran into most of the time were unbalanced quotation marks.

The final goal is it to convert the data into a numeric value (total inches or cm) to open it up for numeric procs for better analysis.


Any suggestions are very much appreciated!bas

2 REPLIES 2
Reeza
Super User

Use KSharp's solution from the tread above but change your scan options, to reflect your data.

Probably work on getting the scan to work properly first is a good place to start.

Tom
Super User Tom
Super User

If the data consistently includes FEET value then you could use something like this:

data check;

input charvar $10.;

inches = sum

(12*input(scan(charvar,1,'"'''),5.)

,input(scan(charvar,2,'"'''),5.)

)

;

put (inches charvar) (=);

cards;

5' 8"

4'

run;

inches=68 charvar=5' 8"

inches=48 charvar=4'

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
  • 2 replies
  • 11145 views
  • 2 likes
  • 3 in conversation