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

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!

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
  • 2282 views
  • 4 likes
  • 3 in conversation