Search found 1801 matches

by Gregory Martin
September 22nd, 2011, 1:55 pm
Forum: Entry
Topic: ERROR:You must assign the result of the function to an alpha
Replies: 12
Views: 12628

Re: ERROR:You must assign the result of the function to an a

For the benefit of other users, one way to code this would be like this: if not poschar ( "A" ,Q1) then skip to Q3; endif ; The poschar function will search the whole Q1 string, looking for "A." If it finds "A" it will return the position of that character. Otherwise it...
by Gregory Martin
September 22nd, 2011, 1:51 pm
Forum: Entry
Topic: do varying (help)
Replies: 2
Views: 4187

Re: do varying (help)

I would write the code like this, without using a loop: PROC Q132_DECLCONF if Q132_DECLCONF = "F" then // F alone skip to Q135_PROBPROFES; elseif poschar ( "ABCDE" ,Q132_DECLCONF) and poschar ( "F" ,Q132_DECLCONF) then // F found with another letter errmsg ( "You c...
by Gregory Martin
September 22nd, 2011, 1:44 pm
Forum: Tabulation
Topic: Tabulation with Alpha fields
Replies: 7
Views: 16525

Re: Tabulation with Alpha fields

Unfortunately, only numeric values can be tabulated. In general in CSPro, if you want to convert an alpha string to a number, you can use the tonumber function. It would take some more advanced programming, but you could use the working storage dictionary, and the labels in it, to indirectly create ...
by Gregory Martin
September 22nd, 2011, 1:01 pm
Forum: Entry
Topic: multi occurrence
Replies: 9
Views: 10297

Re: multi occurrence

Hello, The easiest way to do is to use a loop, especially if you have more than two occurrences. See the attachment for an example. The relevant code is pasted here: PROC VALUE numeric i; do i = 1 while i < curocc () if VALUE(i) = VALUE then errmsg ( "Must enter unique value" ); reenter ; ...
by Gregory Martin
August 31st, 2011, 6:54 pm
Forum: Entry
Topic: Help logic code, answers to sub-answers
Replies: 4
Views: 7046

Re: Help logic code, answers to sub-answers

You can use the setvalueset function to change the value set for a field. So you might create three value sets for the field and then you would write logic like this: PROC Q1 if Q1 = 1 then setvalueset (Q2,Q2_VS1); elseif Q1 = 2 then setvalueset (Q2,Q2_VS2); elseif Q1 = 3 then setvalueset (Q2,Q2_VS3...
by Gregory Martin
August 31st, 2011, 6:50 pm
Forum: Entry
Topic: How to control the scrolling programming (previus or next
Replies: 3
Views: 4762

Re: How to control the scrolling programming (previus or nex

This is an interesting idea, and you are right that it doesn't sound possible the way that OnKey currently works. May I ask what your intention is with checking whether or not the user is clicking on Previous or Next? Might you be able to trap such events using KillFocus. By the way, the Census Bure...
by Gregory Martin
August 31st, 2011, 6:39 pm
Forum: Feature Requests
Topic: Do Cspro an open source project
Replies: 5
Views: 11816

Re: Do Cspro an open source project

At times the Census Bureau has given out code for CSPro, so if you are a developer, you should contact them and ask for some of the source code. For instance, other software packages have created ways to read or write CSPro dictionaries and data files, and they have gotten code from the Census Burea...
by Gregory Martin
June 29th, 2011, 1:14 am
Forum: Other
Topic: Creating a Sample Data File
Replies: 0
Views: 38065

Creating a Sample Data File

If you want to create a simple sample data file (perhaps to test tabulations or edits instead of using the complete data file), you can create a small batch program to select cases to output. For instance, this program selects every twentieth case to generate a 5% sample: PROC GLOBAL numeric sampleP...
by Gregory Martin
June 29th, 2011, 1:14 am
Forum: Other
Topic: Using execsystem to Retrieve a Computer's Username
Replies: 1
Views: 4744

Using execsystem to Retrieve a Computer's Username

An example of when this could be useful is if you want to create a PFF file with the data file named after the login ID of the keyer who has logged onto that machine. PROC GLOBAL alpha ( 20 ) tempFilename = "tempusername.txt" ; alpha ( 300 ) str; FILE inputFile; alpha ( 50 ) username; PROC...
by Gregory Martin
June 29th, 2011, 1:08 am
Forum: Entry
Topic: Randomizing the Order of Questions
Replies: 8
Views: 12438

Randomizing the Order of Questions

In CSPro there is no simple way to change the order that questions are asked in a data entry application, but it can be done with some logic. The following code is an example of how one can use logic to randomize the order that questions are asked. The code randomizes the order in which five questio...