Strange: Saving numeric values have different effects

Discussions about editing and cleaning data
Forum rules
New release: CSPro 8.0
Post Reply
pierrew
Posts: 47
Joined: August 8th, 2012, 5:20 am
Location: Pohnpei, Federated States of Micronesia

Strange: Saving numeric values have different effects

Post by pierrew »

Hey Gents!
I got another weird bug, it is pretty long so here it goes -
I am trying to set imputation flags and use the <impute> function all in one line so I am using a numeric function to compress the code.
If I use this line of code -
flag_original_value(tmp) = edit("ZZZZZZZZZZZZZZZ9",getvaluenumeric(name,occNum));
flag_new_value(tmp) = maketext("%d",newVal);

The export data will be something like this -
[116][Q20906][8][1][NOTAPPL][-------]

If I replace the above line of code with this -
flag_original_value(tmp) = maketext("%d",getvaluenumeric(name,occNum));
flag_new_value(tmp) = maketext("%d",newVal);

The export data will be something like this -
[116][Q20906][8][1][-------][1------]

It's not a big deal but I would like to export to specifically show [NOTAPPL] and [1-----], not [-------][1------].
I can always write extra code to force CSPro to write NOTAPPL but I think the biggest concern is the blank values [------] being displayed when there is an actual value.

I can compress the scripts and send the whole package if you want. Thanks.

Thanks,
Pierre

Code: Select all

//Here is the call statement - 
impute(Q20906, setNumFlag("Q20906",curocc(),1,getdeck(hd_20906_fr_tenure_expCode)));

//Here is the function - 
function setNumFlag(string name, occNum, impType, newVal)
	numeric tmp;
	tmp = noccurs(FLAGS)+1;
	insert(FLAGS_EDT(tmp));
	flag_quest_name(tmp) = name;
	flag_occ_num(tmp) = occNum;
	flag_imputation_type(tmp) = impType;
	if occNum = 0 then
		flag_original_value(tmp) = edit("ZZZZZZZZZZZZZZZ9",getvaluenumeric(name));
	else
		//flag_original_value(tmp) = maketext("%d",getvaluenumeric(name,occNum)); // this commented out for a reason.
		flag_original_value(tmp) = edit("ZZZZZZZZZZZZZZZ9",getvaluenumeric(name,occNum));
	endif;	
	flag_new_value(tmp) = maketext("%d",newVal);
	setNumFlag = newVal;
end;
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Strange: Saving numeric values have different effects

Post by josh »

Pierre - I'm not understanding the issue here. Is the issue that maketext displays notappl as blank and edit displays it as notappl? They have completely different implementations so I'm not surprised they give different results. If you want to see the "notappl" displayed can't you just use edit?
pierrew
Posts: 47
Joined: August 8th, 2012, 5:20 am
Location: Pohnpei, Federated States of Micronesia

Re: Strange: Saving numeric values have different effects

Post by pierrew »

Hey Josh,
Long time no hear. Hope you are doing good. Anyways, so here is the problem -
I agree with you that the display of the <maketext> and <edit> functions have different displays of the NOTAPPL text.
The problem occurs on the next line -
flag_new_value(tmp) = maketext("%d",newVal);

"flag_new_value(tmp)" will fail to save the value from "maketext("%d",newVal)" only if I use this line of code
flag_original_value(tmp) = maketext("%d",getvaluenumeric(name,occNum));

However, if I use this line -
flag_original_value(tmp) = edit("ZZZZZZZZZZZZZZZ9",getvaluenumeric(name,occNum));

everything is ok.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Strange: Saving numeric values have different effects

Post by josh »

I'm doing well Pierre.

Alright, this is an odd one. I think we will need to see the app to look at in context.
Post Reply