BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TurnTheBacon
Fluorite | Level 6

1) I'm setting up mappings in the File Reader transformation. What kind of expression can I use to transform a numeric variable into a character variable? I tried put(varname, $6.) without any success, and can't seem to find any solutions for the kind of syntax I need for typing expressions.

2) When writing expressions, how do I indicate a blank character? I've tried varname IS NULL, varname = NULL, varname = "", and more, to no avail.

Thanks for your time.

1 ACCEPTED SOLUTION

Accepted Solutions
shivas
Pyrite | Level 9

Hi ,

Check this..

file.PNG

expression:

put(SERIAL_NO ,best.)

output:

file1.PNG

2) case when varnum=''  then InstrumentID else varnum end

Thanks,

Shiva

View solution in original post

2 REPLIES 2
shivas
Pyrite | Level 9

Hi ,

Check this..

file.PNG

expression:

put(SERIAL_NO ,best.)

output:

file1.PNG

2) case when varnum=''  then InstrumentID else varnum end

Thanks,

Shiva

Patrick
Opal | Level 21

The result of a put() function is a string but you need to use a numeric format for numeric variables so something like "put(varname,6.)"

The most generic SAS syntax to check for missings is function "missing()" as it deals with both character and numeric variables. "missing()" returns a '1' (='true') it the variable is missing.

For simple If..then..else situations using coalesce() is often an alternative. coalesce() will pick the first non-missing value from a list of values  "coalesce(variable1,variable2,0)"

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 2268 views
  • 4 likes
  • 3 in conversation