How to avoid this note..

Accepted Solution Solved
Reply
Contributor
Posts: 64
Accepted Solution

How to avoid this note..

If scan(dateofquery,1,'/')='unk' and 16<=input(scan(dateofquery,2,'/'),2.)<=31 then

10348! substr(scan(dateofquery,1,'/'),1)='9';

              -

              356

NOTE 356-185: The SUBSTR pseudo-variable function does not allow character constants, expressions, or

              numeric constants for the first argument.

Please help me out..

Thanks in Advance..

--

Durga


Accepted Solutions
Solution
‎08-27-2013 01:50 PM
Respected Advisor
Posts: 4,659

Re: How to avoid this note..

The note is about scan(dateofquery,1,'/') which is a NEW, temporary string, not a substring of dateOfQuery.So, if you replaced it, you would simply be replacing a temporary string, and NOT changing dateOfQuery.

I suggest you use:

If scan(dateofquery,1,'/')='unk' and 16<=input(scan(dateofquery,2,'/'),2.)<=31 then dateOfQuery = transtrn(dateOfQuery, "unk", "9");

PG

PG

View solution in original post


All Replies
Super User
Posts: 10,538

Re: How to avoid this note..

It looks like you are either trying to set a value withing the string. Your variable name dateofquery makes me think you have a string variable which would benefit from being a sas Date variable.

With a string variable you want to use concatenation if your objective is to set the first value before the first / to 9.

Something like

<if clause>

dateofquery= cats('9',substr(dateofquery,(index(dateofquery,'/')));

Contributor
Posts: 64

Re: How to avoid this note..

Hi Ballardw,

My data looks like this

unk/10/1985
5/1/1983
9/17/1990
8/20/1989
9/22/1982
1/29/1990
4/unk/1985
4/30/1985
12/25/1986
12/22/1978
unk/21/1985
12/14/1985
7/16/1988
8/17/1990
10/20/1979
10/4/1988
4/9/1989
6/unk/1991

I have to replace unk's with month or day.. based on conditions ...  it is mmddyy10. format.. you can use my above condition..  or here are specifications

If month is between 1 to 6 then day=1

If month is between 7 to 12 then day=30

If Day is between 1 to 15 then month is 3

If day is between 16 to 30 then month is 9

Thanks In advance..

Solution
‎08-27-2013 01:50 PM
Respected Advisor
Posts: 4,659

Re: How to avoid this note..

The note is about scan(dateofquery,1,'/') which is a NEW, temporary string, not a substring of dateOfQuery.So, if you replaced it, you would simply be replacing a temporary string, and NOT changing dateOfQuery.

I suggest you use:

If scan(dateofquery,1,'/')='unk' and 16<=input(scan(dateofquery,2,'/'),2.)<=31 then dateOfQuery = transtrn(dateOfQuery, "unk", "9");

PG

PG
Contributor
Posts: 64

Re: How to avoid this note..

Thank You PG stats..

Super User
Posts: 10,538

Re: How to avoid this note..

Much better than mine. I keep forgetting about TRANSTRN as most of the data I'm involved with is all too likely to have repeat string values but I only want to replace one specific.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 274 views
  • 5 likes
  • 3 in conversation