BookmarkSubscribeRSS Feed
Chang
Quartz | Level 8

hi,

 

I am running SAS9.4 under 64 bit Windows 7. My format script file has been running without problems for months. However, I started to get the error today. What is confusing me is that the error didn't appear every time. For example, when the script was run I got:

 

SASerror180-322_01_proc_format_error_statement_not_valid.png

 

When the the same script was run again without changing anything, I got:

 

SASerror180-322_02_error_gone.png

 

The syntax structure in this file is basically one proc format with about 20 VALUE statements, where numeric formats are placed before character formats. I just keep adding the formats I want in the same file. I didn't have any errors before today. I've read another post with the same title. I've checked my script and I didn't find missing semicolons in the file. I thought the semicolons in my commentary may be causing the error. So I tried to delete as many as possible. I tried to reboot my laptop and rerun the script. All these did not make a difference. I got the same error in the first run and no error in the next run. 

 

I am copying my script. It is quite long and heavily commented. You can download the file attached

 

/*===============================================================================
Program Name  		:  NU_002_create_formats_variableExplanation.sas
Path                			:  
Program Language	:  SAS V9.4 	
Operating System    :  Win7 64bit
Date created				:	20160529
Note							: 	
	(1) If you do not use the library = option on the proc format statement, the formats are by default stored in 
		work.formats and exist only for the current SAS session. If you specify only a libref, the formats are 
		permanently stored in libref.formats.
	(2) format name cannot end in a number
_______________________________________________________________________________________
Purpose             		:  create formats similar to 
Run Dependencies	:  NU_005_cronbach_coefficient_alpha.R
Macro Calls   
	External          		: 	
  	Internal          		:	
Files  
  Input             			:	
  Output            		: 	
Program Flow        	: 
    1. run this file before the self-defined formats can be appiled in other files
	2. place formats in an alphabetic order similar to NIS variable names
	3. format names can't end with a number so an underscore has been added
--------------------------------------------------------------------------------------------------------------------------------------
variable		Explanation
--------------------------------------------------------------------------------------------------------------------------------------
ID/TWID		
	(1) family w/ MULTIB=2 and 3 IDs w/ suffix 01, 02, 50. 50 is the non-twin sibling older than 01, 02
	(2) family w/ MULTIB=3 and 3 IDs w/ suffix 01, 02, 50, the 3 ID are same-aged
	(3) family w/ MULTIB=3 and 4 IDs w/ suffix 01, 02, 50, 51. '51' is non-twin sibling older than 01, 02, 50. 01, 02 and 50 are same-aged
	(3) family w/ MULTIB=4 and 5 IDs w/ suffix 01, 02, 50, 51, 52. '52' is non-twin sibling older than 01, 02, 50, 51.
	01, 02, 50, 51 are same-aged 

EQSTART captured the time of entering the survey page.

EQEND captured the time when a participant clicked the finish button. If a participant had answered SPHERE 
	questions and then quit the survey without clicking the finish button, his EQEND would be missing. 

ID EQSTART SPHERE12 EQEND	Explanation
-----------------------------------------------------------
A		Y				.			  	  .				see exp1
A		Y				Y				  .				see exp2 
B		Y				Y				 Y				see exp3 
-----------------------------------------------------------
exp1: person A entered survey but didn't answer SPHERE questions, nor did he click finish button	
exp2: person A answered SPHERE questions but didn't click finish button
exp3: person B answered SPHERE questions and clicked finish button

MULTIB		Number of infants born together. Triplets when MULTIB=3.

ZYGOSITY	(1) values should be exactly the same in twin1 (ID suffix=01) and twin2 (ID suffix=02), termed 
	concordant zygosity. Otherwise discordant zygosity, should be reported to Kerrie. 
	(2) ZYGOSITY is not necessarily the same among triplets. zygosity of twin1 (ID suffix=01) is absoluted whereas zygosity 
	of twin2 (ID suffix=02), and ID suffix=50 is determined based on how they are related to twin1. 
	So there may be ZYGOSITY=1,1,3 where twin1 and twin2 are MZFF, and twin1 and ID suffix=50 are DZFF
____________________________________________________________________________*/

proc format ;

/*---------------------------------------formats for numeric values-------------------------------------------*/
	value ENDSTAT
		1 = 'complete'
		15 = 'incomplete	refused'
		16 = 'refused - hostile'
		17 = 'refused - non-hostile (polite, busy etc)'
		20 = 'lost contact'
		21 = 'dead'
		22 = 'invalid (eg relative filled out questionnaire)'
		23 = 'incapable (eg senile, demented)'
		25 = 'partial completion'
		27 = 'overseas'
		50 = 'return to sender'	
		51 = 'telephone contact'	
		61 = 'doctor refused patient contact'
		;

value ENDSTAT_NU3_
		1 = 'Interview completed' 
		2 = 'Interview partially completed' 
		3 = 'Interview in progress' 
		4 ='Completed under other ID' 
		5 = 'Unable to contact' 
		6 = 'Project Closure ? in progress' 
		7 = 'Project Closure ? no contact made' 
		8 = 'Project Closure ? 12month + outstanding' 
		19 = 'Lead given to IVER' 
		20 = 'Lost Contact' 
		21 = 'Deceased' 
		22 = 'ineligible' 
		23 = 'Incapable' 
		24 = 'No interview - exceptional cases/circumstances' 
		25 = 'No telephone' 
		26 = 'Silent number' 
		27 = 'Overseas' 
		50 = 'Return to sender' 
		51 = 'Sibling and twin overlap - check ATR' 
		54 = 'Silent number/no telephone/letter sent' 
		55 = 'Delay contact - study crossover' 
		56 = 'Delay contact' 
		58 = 'Deleted at PI request' 
		59 = 'Sibling ineligible - outside age limit' 
		60 = 'Refused by screening twin' 
		61 = 'Refusal - positive (1)' 
		62 = 'Refusal - mildly negative (2)' 
		63 = 'Refusal - moderately negative (3)' 
		64 = 'Refusal - very negative (4)' 
		65 = 'Refusal - extremely negative (5)' 
		68 = 'Refusal ? passive' 
		88 = 'Absolutely lost (Family/ATR/Telstra)'
		;
	
	value pValue_color1_ /*p<0.001 in red, else in black*/
	    low - 0.001= 'red' 
	    0.001 <- high = 'black'
		; 

/*this format= study names in table 1, manuscript*/
	value studyNameManuscript01_
		1='TW1'
		2='TW2'
		3='TM'
		4='TA'
		5='NU'
		6='NU diagnoses'
		;
/*---------------------------------------formats for character values-------------------------------------------*/
	value $ID_suffix
		'01' = 'twins'
		'02' = 'twins'
		'53' = 'parents'
		'54' = 'parents'
		'50' = 'siblings'
		'51' = 'siblings'
		;
	value $openmxModelNames
		'CholACE'=	'Cholesky ACE'
		'IndACE'=	'IP'
		'Ind2Ace'=	'IP2A'		
		'Ind3Ace'=	'IP3A'
		'ComACE'=	'CP'
		;
	value $NU_phase
		'NU.NULOG'=				'NU1'
		'NU.NULOG2'=			'NU2'
		'NU.NULOG3'=			'NU3'
		'NU.NULOG_pooled'=	'All waves'
		;

/*omitSPHERE12Item1 to omitSPHERE12Item12 must match elements in object "itemOmit" 
in NU_005_cronbach_coefficient_alpha.R*/

	value $SPHERE12_questions
		"omitSPHERE12Item1"=		"1. Feeling nervous or tense?" 
		"omitSPHERE12Item2"=		"2. Feeling unhappy and depressed?"
		"omitSPHERE12Item3"=		"3. Feeling constantly under strain?"
		"omitSPHERE12Item4"=		"4. Everything getting on top of you?"
		"omitSPHERE12Item5"=		"5. Losing confidence?"
		"omitSPHERE12Item6"=		"6. Being unable to overcome difficulties?"
		"omitSPHERE12Item7"=		"7. Muscle pain after activity?"
		"omitSPHERE12Item8"=		"8. Needing to sleep longer?"
		"omitSPHERE12Item9"=		"9. Prolonged tiredness after activity?"
		"omitSPHERE12Item10"=	"10. Poor sleep?"
		"omitSPHERE12Item11"=	"11. Poor concentration?"
		"omitSPHERE12Item12"=	"12. Tired muscles after activity?"
			;

/*These formats are to be used with varGroup in file "ROut_NU_allDiagnoses_varNames.xlsx"	*/
/*These formats do not uniquely identify variable values*/
	value $var_P6_S6_AFF_SUD
/*binary diagnoses*/
		'agoraphobia_DSM5'=				'agoraphobia'
		'AlcoholEver'=							'alcohol use'
		'depressiveEpisode_DSM5'=	'depressive episodes'

/*recode dsm5_AUD as 0 if control or mild, as 1 if moderate or severe*/
		'dsm5_AUD_bin1'=					'alcohol use disorder' 

/*recode dsm5_AUD as 0 if control, mild, moderate,  as 1 if severe*/
		'dsm5_AUD_bin2'= 					'alcohol use disorder severity'
		'dsm5_AUD'= 							'alcohol use disorder'
		'dsm5_CUD_binary'=				'cannabis use disorder'
		'dsm5_CUD'=							'cannabis use disorder'
		'hypomanicEpisode_DSM5'=	'hypomanic episodes'
		'IllegalDrugsEver'=					'drug use ever'
		'MarijuanaEver'=						'cannabis use ever'
		'MDD_DSM5'=						'major depressive disorder'
		'panicAttack'=							'panic attack'
		'panicDisorder_DSM5'=			'panic disorder'
		'PsychosisLast12months'=		'psychosis symptoms last 12 months'
		'PsychosisSymptomPresence'=	'psychosis symptoms lifetime'
 		'socialAnxietyDiag_DSM5'=	'social anxiety' 
		'TobaccoEver'=							'tobacco use ever'

/*continuous variables*/
		'AnxDep6Final_theta_13'				=	'<13'
		'AnxDep6Final_theta_13_r'			=	'<13'
		'AnxDep6Final_theta_13_15'		=	'13-15'
		'AnxDep6Final_theta_13_15_r'	=	'13-15'
		'AnxDep6Final_theta_15_17'		=	'15-17'
		'AnxDep6Final_theta_15_17_r'	=	'15-17'
		'AnxDep6Final_theta_17'				=	'17-19'
		'AnxDep6Final_theta_17_r'			=	'17-19'
		'PSYCH6'										=	'19+'
		'PSYCH6_IRT'								=	'PSYCH6-IRT'  /* 'PSYCH6_IRT'	=	'19+'*/
		'PSYCH6_IRT_r'							=	'PSYCH6-IRTr' /*'PSYCH6_IRT_r'	=	'19+'*/
		'Fatigue6Final_theta_13'				=	'<13'
		'Fatigue6Final_theta_13_r'			=	'<13'
		'Fatigue6Final_theta_13_15'		=	'13-15'
		'Fatigue6Final_theta_13_15_r'		=	'13-15'
		'Fatigue6Final_theta_15_17'		=	'15-17'
		'Fatigue6Final_theta_15_17_r'		=	'15-17'
		'Fatigue6Final_theta_17'				=	'17-19'
		'Fatigue6Final_theta_17_r'			=	'17-19'
		'SOMA6'										=	'19+'
		'SOMA6_IRT'								=	'SOMA6-IRT' /*'SOMA6_IRT'	=	'19+'*/
		'SOMA6_IRT_r'							=	'SOMA6-IRTr' /* 'SOMA6_IRT_r'	=	'19+'*/
		'IRT_affectDisorders'					=	'AFF-IRT'
		'IRT_affectDisorders_r'					=	'AFF-IRT'
		'IRT_subsUseDisorder'					=	'SUD-IRT'
		'IRT_subsUseDisorder_r'				=	'SUD-IRT'
			;

	value $var_P6r_S6r_AFFrSUDr
/*continuous variables*/
		'AnxDep6Final_theta_13_r'			=	'PSYCH6-IRTr age <13' 
		'AnxDep6Final_theta_13_15_r'	=	'PSYCH6-IRTr age 13-15'
		'AnxDep6Final_theta_15_17_r'	=	'PSYCH6-IRTr age 15-17'
		'AnxDep6Final_theta_17_r'			=	'PSYCH6-IRTr age 17-19'
		'PSYCH6_IRT_r'							=	'PSYCH6r' /*'PSYCH6_IRT_r'	=	'PSYCH6-IRTr age 19+'*/
		'Fatigue6Final_theta_13_r'			=	'SOMA6-IRTr age <13'
		'Fatigue6Final_theta_13_15_r'		=	'SOMA6-IRTr age 13-15'
		'Fatigue6Final_theta_15_17_r'		=	'SOMA6-IRTr age 15-17'
		'Fatigue6Final_theta_17_r'			=	'SOMA6-IRTr age 17-19'
		'SOMA6_IRT_r'							=	'SOMA6r ' /* 'SOMA6_IRT_r'	=	'SOMA6-IRTr age 19+' */
		'IRT_affectDisorders_r'					=	'AFFr'
		'IRT_subsUseDisorder_r'				=	'SUDr'
			;

	value $ZYGOSITY_abbr
		'1'='MZFF' 
		'2'='MZMM' 
		'3'='DZFF'
		'4'='DZMM'
		'5'='DZFM' 
		'6'='DZMF'		
		'9'='Unknown'
		;
	 value $zygo5Groups
		'1'=	'MZFF' 
		'2'=	'MZMM' 
		'3'=	'DZFF'
		'4'=	'DZMM'
		'5'=	'DZO' 
		;
	 value $ZYGOSITY_full
		'1'='MZ female' 
		'2'='MZ male' 
		'3'='DZ female'
		'4'='DZ male'
		'5'='DZ twins where the female was born first' 
		'6'='DZ twins where the male was born first' 		
		'9'='Zygosity not known or unsure'
		;		
run;
/*-------------------------------This is the end of this program-----------------------------------------------*/
8 REPLIES 8
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Its hard to tell from what you posted, however somewhere along the line it is thinking that the proc format; statement is a comment or something similar, and hence ignoring that.  Thus the code becomes wrong as proc format is missing.  As I said its near on immpossible for us to determine from what you have posted, it could be an unfinished comment in the program, or any of the other myria of programs such as startup or other files, or comments left over from another run etc.  If it was me I would, start a completely new session - check the log and do something simple like proc sort a sashelp.class dataset just to check code is running.  Once you have done that load your formats file as you have given below, and run that - I would also remove all the comment section at the top before doing this.  Then you can see if your code is good, which it seems to, and then try to trace where the error is coming in.  Note I would never recommend having huge comment blocks in code like that.  Following SDLC you would have a document which details the whole process in detail, so this type of commenting is both redundant, hard to maintain as its all manual, and can introduce errors (like unfinished comments) if your not carefull

Chang
Quartz | Level 8

hi RW9,

 

thanks for the suggestion. I've figured out the problem is that some macro variables were wrongly created. I store table titles and footnotes in an excel file. Macro variables are created using the column manuscriptSection and number. Data from this file was not imported properly, resulting in an empty line as the last row. That was how I got caught when the macro variables were used in other table files.

 

SAS_error_caused_by_reading_excel.png

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Good example of overcomplicating processes - 

(Lots of macro code + lots of macro variables + using Excel) - AnyDocmentation = glass programming, i.e. will break at anything other than a mere glance.

Chang
Quartz | Level 8

hi,

 

I am running SAS9.4 under 64 bit Windows 7. I have a master file that generates a RTF files with multiple tables. The file has been running without problems for months. I am surprised that I got the following warning. To make the matter worse, my RTF file didn't pop up as usual but I didn't have any error in the log.

 

SAS_warning_quoted_string_more_than_262_characters_long.png

 

The syntax structure in this file is one ODS RTF and one ODS RTF close statement with code blocks between them. Each code block executes a separate SAS file that has a PROC REPORT for a table. I usually place few code blocks between the ODS RTF and ODS RTF close to generate wanted tables. A RTF file usually pops up when the code is run. However, I am getting the warning above and no RTF file appears. I've checked my script several times for missing semicolons. Rebooting my laptop and rerunning the script didn't make a difference. I don't think there are problems in the PROC REPORT files called by the code block, as they have been used again and again.

 

You may download my script file or just refer to the following script. I have included just one code block for a table. The macro variables (e.g. &analytical_output, &proj_dir, &tables)  for defining the directory of the files are executed in another file not shown here.

 

 

/*====================================================================
Program Name  		:	NU_020_tables_master.sas
Programmer				:	Chang
Path                			:	D:\Now\library_genetics_epidemiology\slave_NU\NU_analytical_programs
Program Language	:	SAS V9.4 	
Operating System   	:	Windows 7 professional 64bit
Date created				:	20160612
Global setting			: 	Font=TimeNewRomans, size=16
Office PPT setting	:  To make the columns in a table automatically fit the contents, 
										click on your table. 
										On the Layout tab, in the Cell Size group, click AutoFit, and then click AutoFit Contents.
NOTE						:	
(1) one-line per row in the table if colAlign=left. Note colAlign=d will show last colum as two lines, tho it looks nicer
___________________________________________________________________________
Purpose             		:  execute subsequent table files, create a single table from each, export the tables in a single RTF 
Run Dependencies 	:  
Macro Calls   
	External          		: 	see the list of SAS macro files in the &list.
  	Internal          		:	
Files  
  Input             			:	
  Output            		: 	
Program Flow        	: 	
Naming					:	file names of individual table have 3 parts (e.g. NU_028b_table_uniVarBin_prevaThresCorr.sas)
									(1) project short (NU)
									(2) serial number (028b) to group relevant analyses of same variable together. 
										 Don't attempt to make them unique!
									(3) text of "table" to distinguish table script files from other type of script files
									(4) unique part of the file (e.g. uniVarBin_prevaThresCorr)
____________________________________________________________________________*/

/**********************************************************************************************
*date			modifications
----------------------------------------------------------------------------------------------------------------------------------------
20160704	merged correlation simple statistics with pearson correlation and spearman correlation
20160612	program modified from 
	"D:\z_old_files\FBCCRO_server_backup\KA130020_Olsaa\15-Analysis Preparation\15.1-Listing Program\Olsaa_dataList_04_make_one_report.sas"
---------------------------------------------------------------------------------------------------------------------------------------*/

/************************************************************************************************/
/*section02	:	customise the style of the outputed RTF reports */
/* ref systemp option NOQUOTELENMAX : http://support.sas.com/resources/papers/proceedings11/262-2011.pdf*/
/*-----------------------------------------------------------------------------------------------------------------------*/
options	missing = ' '  	/*Specifies the character to print for missing numeric values.*/ 
			center 			/*Specifies whether to center or left align SAS procedure output*/
			nodate 			/*suppress default print of data time that this SAS program executed*/
			nonumber 	/*suppress default print of page number on first title line of each page*/
			orientation=landscape
			/*orientation=portrait*/
		;
/*------------------------------------------------------changing table margins------------------------------------------------------*/
options	bottommargin = 	0.5 cm 
   		topmargin = 				0.5 cm 
   		rightmargin = 			0.5 cm /*0.5in */
   		leftmargin = 				0.5 cm /*0.5in */
		; 

/*suppress the warning that a quoted string that exceeds 262 characters in length*/
options NOQUOTELENMAX ; 

ods _all_ close; 
ods rtf file=		"&proj_dir.\&analytical_output.\NU_tables_%sysfunc(date(), yymmdd10.).rtf" 
		style=		Journal 
		contents 
		toc_data ; /*show table of contents*/

/*----------------------------------------Perform in-line formatting----------------------------------------------------------*/
/* first tell ODS what character will be used as the ODS ESCAPECHAR character value*/
ods escapechar='~';
ods escapechar='^';

/*add the company logo at first line*/
/*title 	j=l 
		"~S={preimage=	'D:\Now\library_genetics_epidemiology\slave_NU\NU_images\Logo_of_the_QIMR_small.png'	}	"
	;*/

/*Add study name at left end of 2nd line*/
title2	j=l 										/*left-aligned*/
			font='Times New Roman' 
			h=10pt 'Study: The 19 (NU) Up Study'
	;	
/*Add page number at right end of line 3*/
title3 j=R  /*right-aligned*/
		font='Times New Roman' 
		h=10pt 'Page ~{thispage} of ~{lastpage}'
	;

/*-----------------------------------------------------------------------------------------------------*/
/*----------------START manuscript Table section--------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------*/

/*-------------------------------------table titles--------------------------------------------------*/
%let tableTitles= NU_019_table_itles_footnotes.sas ;
%include "&proj_dir.\&analysis.\&tableTitles.";

/*-------1 variate: twin counts, age beta, sex beta, twin counts, rMZ, rDZ, heritability----------*/
/*ODS_style_conditionally_bold01.png*/
/*cell width totalled= 21.75 cm+ 0.8%*/
%let tDat_1VarBinConOrd_NBetaCorHeri=	out.uniVarBinConOrd_table01; /*out.uniVarBinCon01_02_03_04 out.uniVarBinCon01_02_05  out.uniVarCon01_02_05*/; 
%let tScr_1VarBinConOrd_NBetaCorHeri=	NUtab02_1VarBinConOrd_NBetaCorrHeritability;
%include	"&proj_dir.\&tables.\&tScr_1VarBinConOrd_NBetaCorHeri..sas";

/*-----------------------------------------------------------------------------------------------------*/
/*----------------END manuscript Table section--------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------*/

/*------------------ close ODS RTF device----------------------------------------------------*/
ods rtf close;
ods listing;

 

 

 

 

Chang
Quartz | Level 8

hi ,

 

I clicked your URL and it directed me to my own post. Can you please copy the link again? I've noticed same title has been used by different users. THanks

Kurt_Bremser
Super User

@Chang wrote:

hi @Kurt_Bremser,

 

I clicked your URL and it directed me to my own post. Can you please copy the link again? I've noticed same title has been used by different users. THanks


One of the admins or superusers merged both your questions into one thread.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 11529 views
  • 2 likes
  • 3 in conversation