sas field with spaces

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

sas field with spaces

Hi,

 

I'm using SAS DI for writing some fields into a .csv file. But how is it possible to write a field containg spaces in its name?

Ex.: Considering the field named STATO CLIENTE, the automatically generated code in the FileWriter transformation fails:

 

3180   proc sql;
3181   create view work.WLIS8YD as
3182   select FIELD_OK as THIS_IS_CORRECT,
... 3244 STATO_CLIENTE_CRM as STATO CLIENTE,
22
ERROR 22-322: Expecting a name.  ...

Is it possible to write the fied STATO CLIENTE in the file without removing the space?

 

Thanks.


Accepted Solutions
Solution
‎12-06-2016 06:41 AM
Contributor
Posts: 27

Re: sas field with spaces

Fixed with the following workouround.

The SAS field will be named STATO_CLIENTE and the FileWriter writes STATO CLIENTE only in the header of the file.

View solution in original post


All Replies
Grand Advisor
Posts: 10,210

Re: sas field with spaces

Try

 

STATO_CLIENTE_CRM  label="STATO CLIENTE"

 

SAS generally uses Labels to provide better descriptive text than just the variable name and they allow much more text.

Contributor
Posts: 27

Re: sas field with spaces

Ok, your code doesn't returns errors anymore. After, there are two pieces of code where STATO CLIENTE is used:

 

attrib STATO CLIENTE length = 8
format = 11.
       informat = 11.;

and:

 

	quote='"';
	file 'C:\Users\dlt_gec\Projects\Norma\GDC_ANG_NRM_010_DWH.csv' DSD dlm='|' lrecl=1000;
      
	if ( _n_ = 1 ) then 
	do;
		put "BP_COLLEGATO|CF|CLUSTER_CLIENTE|..."@;
		put	"...SF|STATO CLIENTE|COD_CLIENTE..."@;
		put "RUP|...|IMPORTO_FIDEJUSSIONE";               
	end;
	put 
		BP_COLLEGATO
		CF
		CLUSTER_CLIENTE
        ...
		STATO CLIENTE
		RUP
		...

The job runs without errors but the value in the field STATO CLIENTE is blank; I'm expecting the value 2. Infact, adding a new field TEST, mapped to STATO_CLIENTE_CRM, 2 is correctly writted in the TEST field.

 

What can be the reason that STATO CLIENTE is blank in the file?

Thanks.

Solution
‎12-06-2016 06:41 AM
Contributor
Posts: 27

Re: sas field with spaces

Fixed with the following workouround.

The SAS field will be named STATO_CLIENTE and the FileWriter writes STATO CLIENTE only in the header of the file.

Esteemed Advisor
Posts: 5,198

Re: sas field with spaces

Agree with @ballardw that using spaces is not a best practice.

But sometime source DBMS have them, or if you persists to have them, you can allow this by ticking "Enable special characters within DBMS object names" check box, which is available on every "Physical Storage" tab.

Data never sleeps
Contributor
Posts: 27

Re: sas field with spaces

Hi LinusH,

 

in my case, a field containing a space is not read from a database but a space is needed in an output field into a file.

Anyway, thanks for your suggestions, that could be useful for other cases in the future Smiley Wink

 

Valued Guide
Posts: 2,174

Re: sas field with spaces

Name Literals
' any char 'n

SAS permits blanks in column names but to clarify in use, we must use this style

Select 'name with blanks'n as name_with_blanks label= 'name with blanks'
From database.table
Valued Guide
Posts: 2,174

Re: sas field with spaces

 
☑ This topic is SOLVED.

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

Discussion stats
  • 7 replies
  • 209 views
  • 1 like
  • 4 in conversation