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

Hello,

 

How can I keep the variable as a character value?

 

I running following codes,

%MACRO CompnayNameM(no=,Company_name=);
data step9.Patstat_total_hrm_Step34;
	set step9.Patstat_total_hrm_Step34;
&COMPANY_NAME._Step34=&COMPANY_NAME._Step33;	
&Company_name._S34= tranwrd(&Company_name._S34," A B "," AB ");
&Company_name._S34= tranwrd(&Company_name._S34," A CALIFORNIA CORP "," CORP ");
...
...
...
if find(&Company_name._S34," LTD CO " )>0 then do; 
&Company_name._S34= tranwrd(&Company_name._S34, " LTD CO ", " CO LTD ");FlagGB=1;end;   	
c&Company_name._33v34= (&COMPANY_NAME._S34 ne &Company_name._S33);	
run;


	data PATSTAT34&no.(keep=&Company_name. &Company_name._S33 &Company_name._S34 c&Company_name._33v34);
		set step9.Patstat_total_hrm_Step34;
		if c&Company_name._33v34=1  ;
	run;

%MEND CompnayNameM;
%CompnayNameM(no=1,Company_name=HRM_L2)
%CompnayNameM(no=2,Company_name=PERSON_NAME)
%CompnayNameM(no=3,Company_name=HRM_L2inB)
%CompnayNameM(no=4,Company_name=HRM_L2noB)
%CompnayNameM(no=5,Company_name=PERSON_NAMEinB)
%CompnayNameM(no=6,Company_name=PERSON_NAMEnoB)
%CompnayNameM(no=7,Company_name=HRM_L2_BinB)
%CompnayNameM(no=8,Company_name=HRM_L2_BnoB)
%CompnayNameM(no=9,Company_name=PERSON_NAME_BinB)
%CompnayNameM(no=10,Company_name=PERSON_NAME_BnoB)
%CompnayNameM(no=11,Company_name=HRM_L2_B)
%CompnayNameM(no=12,Company_name=PERSON_NAME_B)
run;

get the result like

WARNING: Apparent symbolic reference D not resolved.
WARNING: Apparent symbolic reference D not resolved.
WARNING: Apparent symbolic reference D not resolved.
WARNING: Apparent symbolic reference D not resolved.
WARNING: Apparent symbolic reference D not resolved.
WARNING: Apparent symbolic reference D not resolved.

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
      1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1
      1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1
 ...
...
      1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1
      1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1   1:1
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      1:145     1:209     2:55      2:133     2:206     3:22      3:92      3:165     3:245
      5:73      5:153     5:232     6:67      6:139     6:212     7:34      7:106     7:197
...
...

      319:22    319:93    319:165   319:237   321:64    321:147   321:233   322:67    322:141
      322:210   323:33    323:106   323:179   325:2     325:85    325:167   326:2     326:78
      326:227   327:134   329:35    329:174   330:72    330:212   1:2
NOTE: Variable HRM_L2_Step33 is uninitialized.
NOTE: Invalid numeric data, HRM_L2_S33='OBAC' , at line 1 column 2.
HRM_L2=!OBAC PERSON_CTRY_CODE=GB PERSON_NAME=!OBAC LIMITED SECTOR=COMPANY
PERSON_ADDRESS=1st & 2nd Floors, Elizabeth House, Les Ruettes Bray,Guernsey 1EW HRM_L2_B=
PERSON_NAME_B=  HRM_L2inB=  HRM_L2noB=  PERSON_NAMEinB=  PERSON_NAMEnoB=  HRM_L2_BinB=  HRM_L2_BnoB=
PERSON_NAME_BinB=  PERSON_NAME_BnoB=  HRM_L2_S33=OBAC PERSON_NAME_S33=OBAC LIMITED HRM_L2inB_S33=
HRM_L2noB_S33=  PERSON_NAMEinB_S33=  PERSON_NAMEnoB_S33=  HRM_L2_BinB_S33=  HRM_L2_BnoB_S33=
PERSON_NAME_BinB_S33=  PERSON_NAME_BnoB_S33=  HRM_L2_B_S33=  PERSON_NAME_B_S33=  HRM_L2_Step34=.
HRM_L2_Step33=. HRM_L2_S34=. FlagGB=. cHRM_L2_33v34=0 _ERROR_=1 _N_=1
NOTE: Invalid numeric data, HRM_L2_S33='OBAC' , at line 1 column 2.
HRM_L2=!OBAC PERSON_CTRY_CODE=GB PERSON_NAME=!OBAC Limited SECTOR=COMPANY
PERSON_ADDRESS=1st & 2nd Floors, Elizabeth House, Les Ruettes Brayes, St. Peter Port,Guernsey GY1 1EW
HRM_L2_B=  PERSON_NAME_B=  HRM_L2inB=  HRM_L2noB=  PERSON_NAMEinB=  PERSON_NAMEnoB=  HRM_L2_BinB=
HRM_L2_BnoB=  PERSON_NAME_BinB=  PERSON_NAME_BnoB=  HRM_L2_S33=OBAC PERSON_NAME_S33=OBAC LIMITED
HRM_L2inB_S33=  HRM_L2noB_S33=  PERSON_NAMEinB_S33=  PERSON_NAMEnoB_S33=  HRM_L2_BinB_S33=
HRM_L2_BnoB_S33=  PERSON_NAME_BinB_S33=  PERSON_NAME_BnoB_S33=  HRM_L2_B_S33=  PERSON_NAME_B_S33=
HRM_L2_Step34=. HRM_L2_Step33=. HRM_L2_S34=. FlagGB=. cHRM_L2_33v34=0 _ERROR_=1 _N_=2

the variable was set as a character value but convert to the numeric value automatically. I think it is why my code does not work. How can I keep the value as a character value? if my thinking is wrong, what should I do?

 

thanks in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Amir
PROC Star

Please confirm what you mean when you say "the variable", which variable are you referring to?

 

The note in your log shows:

NOTE: Variable HRM_L2_Step33 is uninitialized.

 

Should your first assignment be:

&COMPANY_NAME._Step34=&COMPANY_NAME._S33;

 

 

 

instead of "Step33"?

 

Using some diagnostics might help, e.g.:

 

options mprint symbolgen;

 

 

Also you'll probably need to address the log warning:

WARNING: Apparent symbolic reference D not resolved.

 

Regards,

 

Amir.

View solution in original post

2 REPLIES 2
Amir
PROC Star

Please confirm what you mean when you say "the variable", which variable are you referring to?

 

The note in your log shows:

NOTE: Variable HRM_L2_Step33 is uninitialized.

 

Should your first assignment be:

&COMPANY_NAME._Step34=&COMPANY_NAME._S33;

 

 

 

instead of "Step33"?

 

Using some diagnostics might help, e.g.:

 

options mprint symbolgen;

 

 

Also you'll probably need to address the log warning:

WARNING: Apparent symbolic reference D not resolved.

 

Regards,

 

Amir.

ballardw
Super User

Which variable?

"Keep" where?

 

And since your macro has been using

data step9.Patstat_total_hrm_Step34;
	set step9.Patstat_total_hrm_Step34;

replacing the entire data set each time it is called, who knows what data you may have had to begin with.

 

At least run your macro with OPTIONS MPRINT; on to see what code you are generating and get a better idea where things are going off kilter such as the symbolic reference issue.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 889 views
  • 0 likes
  • 3 in conversation